Skip to main content

useShopifyCookies

Sets Shopify user and session cookies and refreshes the expiry time. Returns true when cookies are ready.

Sets the shopify_y and shopify_s cookies in the browser based on user consent for backward compatibility support.

If fetchTrackingValues is true, it makes a request to Storefront API to fetch or refresh Shopiy analytics and marketing cookies and tracking values. Generally speaking, this should only be needed if you're not using Hydrogen's built-in analytics components and hooks that already handle this automatically. For example, set it to true if you are using hydrogen-react only with a different framework and still need to make a same-domain request to Storefront API to set cookies.

If ignoreDeprecatedCookies is true, it skips setting the deprecated cookies entirely. Useful when you only want to use the newer tracking values and not rely on the deprecated ones.

Anchor to options
options

true when cookies are set and ready.



Was this page helpful?