Skip to main content

Search Example

A complete, copy-pasteable search experience built on the Glood Hydrogen Search SDK: config → instant search → full results → filters → image search → attribution events. Take the pieces you need.

1. Client Setup

Register the search app once (alongside recommendations if you use it):
Wrap your app in root.tsx (inside Shopify’s Analytics.Provider):

2. Don’t Forget the CSP

Search fetches and events are blocked by Hydrogen’s default CSP. Add the search origins in entry.server:
Type-ahead search with suggestions, autocorrect and a trending empty state:

4. Full Search Results Page

A results page with filters, sort, pagination, and click/add-to-cart attribution:
Search by an uploaded photo:

6. Server-Side Rendering Variant

To ship results in the initial HTML, fetch in the loader instead of the hook:
With SSR you still get attribution: retrieve the track helpers client-side from useSearch (pass { skip: true } to reuse them without a second fetch), or send events directly with sendSearchEvent(options, event).

7. Standard Events Are Automatic

Once search() is registered, GloodProvider forwards Shopify standard events (product_viewed, search_submitted, product_added_to_cart, …) to the search backend with no extra code. Narrow them if you want:

8. Glood Search Events

On top of the standard events, the Glood search app emits custom attribution events. The search page above already sends the click and filter ones via the track helpers: Each event carries a specific custom_data.track payload on the wire — see the event-wise payload structure in the Search Events API reference for the exact shape of every standard and glood: event.

What You’ll See in the Console (debug: true)

See Also