--- title: Analytics.SearchView description: Publishes a `search_viewed` event to the `Analytics.Provider` component. api_version: 2025-07 api_name: hydrogen source_url: html: >- https://shopify.dev/docs/api/hydrogen/latest/components/analytics/analytics-searchview md: >- https://shopify.dev/docs/api/hydrogen/latest/components/analytics/analytics-searchview.md --- # Analytics.SearchView Publishes a `search_viewed` event to the `Analytics.Provider` component. ## analyticsSearchView([props](#props-propertydetail-props)) ### Parameters * props SearchViewProps required ### SearchViewProps * customData ```ts OtherData ``` * data ```ts SearchPayload ``` ```ts { data?: SearchPayload; customData?: OtherData; } ``` ### OtherData ```ts OtherData ``` ### SearchPayload * searchResults The search results ```ts any ``` * searchTerm The search term used for the search results page ```ts string ``` ```ts { /** The search term used for the search results page */ searchTerm: string; /** The search results */ searchResults?: any; } ``` ### Examples * #### example ##### Description This is the default example ##### JavaScript ```js import {Analytics} from '@shopify/hydrogen'; import {useLoaderData} from 'react-router'; export async function loader({request}) { const url = new URL(request.url); const searchParams = new URLSearchParams(url.search); const searchTerm = String(searchParams.get('q') || ''); return {searchTerm}; } export default function SearchPage() { const {searchTerm} = useLoaderData(); return (