--- title: getTrackingValues description: >- Retrieves user session tracking values for analytics and marketing from the browser environment. api_version: 2026-04 api_name: hydrogen source_url: html: 'https://shopify.dev/docs/api/hydrogen/latest/utilities/gettrackingvalues' md: 'https://shopify.dev/docs/api/hydrogen/latest/utilities/gettrackingvalues.md' --- # getTrackingValues 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() Retrieves user session tracking values for analytics and marketing from the browser environment. ### Returns * **TrackingValues** ### 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 ##### JavaScript ```jsx import {getTrackingValues} from '@shopify/hydrogen'; 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'; 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 [- useShopifyCookies](https://shopify.dev/docs/api/hydrogen/2026-04/hooks/useshopifycookies) [- getShopifyCookies](https://shopify.dev/docs/api/hydrogen/2026-04/utilities/getshopifycookies) ***