--- title: getTrackingValues description: >- Retrieves user session tracking values for analytics and marketing from the browser environment. It reads from `server-timing` headers in Storefront API responses and falls back to deprecated cookies for backward compatibility. api_version: 2026-01 api_name: hydrogen-react source_url: html: >- https://shopify.dev/docs/api/hydrogen-react/latest/utilities/gettrackingvalues md: >- https://shopify.dev/docs/api/hydrogen-react/latest/utilities/gettrackingvalues.md --- # get​Tracking​Values Retrieves user session tracking values for analytics and marketing from the browser environment. It reads from `server-timing` headers in Storefront API responses and falls back to deprecated cookies for backward compatibility. ## get​Tracking​Values() Returns an object containing `uniqueToken`, `visitToken`, and `consent` values. ### Returns * **TrackingValues** ### ### TrackingValues * **consent** **string** Represents the consent given by the user or the default region consent configured in Admin * **uniqueToken** **string** Identifier for the unique user. Equivalent to the deprecated \_shopify\_y cookie * **visitToken** **string** Identifier for the current visit. Equivalent to the deprecated \_shopify\_s cookie ### TrackingValues * consent Represents the consent given by the user or the default region consent configured in Admin ```ts string ``` * uniqueToken Identifier for the unique user. Equivalent to the deprecated \_shopify\_y cookie ```ts string ``` * visitToken Identifier for the current visit. Equivalent to the deprecated \_shopify\_s cookie ```ts string ``` Examples ### Examples * #### Example code ##### Description I am the default example ##### JavaScript ```jsx import {getTrackingValues} from '@shopify/hydrogen-react'; export function sendCustomAnalyticsEvent(eventName) { const {uniqueToken, visitToken} = getTrackingValues(); // Use tracking values in your custom analytics implementation fetch('/api/analytics', { method: 'POST', body: JSON.stringify({ event: eventName, uniqueToken, visitToken, }), }); } ``` ##### TypeScript ```tsx import {getTrackingValues} from '@shopify/hydrogen-react'; export function sendCustomAnalyticsEvent(eventName: string) { const {uniqueToken, visitToken} = getTrackingValues(); // Use tracking values in your custom analytics implementation fetch('/api/analytics', { method: 'POST', body: JSON.stringify({ event: eventName, uniqueToken, visitToken, }), }); } ``` ## Related [Hook - useShopifyCookies](https://shopify.dev/api/hydrogen-react/hooks/useShopifyCookies) [Utility - getShopifyCookies](https://shopify.dev/api/hydrogen-react/utilities/getShopifyCookies)