Skip to main content
Legacy Hydrogen

These pages refer to Hydrogen versions 2026-04 and earlier. For versions 2026-10 and later, refer to the latest Hydrogen docs. If you're not using the latest version of Hydrogen, then we recommend that you migrate your storefront. To learn more, refer to Migrate to the latest version of Hydrogen.

Migrating analytics tracking for custom headless builds

Caution

This configuration isn't officially supported by Shopify.

This guide provides information about maintaining reliable Shopify Analytics data for your custom headless build without using the shopify_y (unique visitor) and shopify_s (session) cookies, which will be deprecated on April 30, 2026.

For Hydrogen apps (React Router/Remix) deployed to Oxygen or to another host, refer to Migrate Hydrogen analytics tracking instead.


Anchor to Implement a Storefront API proxyImplement a Storefront API proxy

To migrate analytics tracking for a custom headless build, implement a Storefront API proxy on your server to handle the new Shopify cookies within your storefront domain (refer to the Hydrogen proxy implementation for an example). You'll use hydrogen-react's useShopifyCookies({fetchTrackingValues: true}) to initiate a request to the Storefront API proxy to retrieve the cookies.

If you're using custom analytics, then replace getShopifyCookies (now deprecated) with getTrackingValues, which is a new export from hydrogen-react. With this utility, uniqueToken corresponds to the former _y value, and visitToken corresponds to the former _s value.


Was this page helpful?