How contextual information works
The Storefront Pixel automatically collects and manages contextual information for standard Shopify integrations. For headless or custom implementations, you must manually include contextual data in your API requests to enable personalization features.Standard Shopify integration
When you install the Layers Storefront Pixel on your Shopify theme, contextual information is automatically:- Collected from the customer’s browsing session and Shopify customer data
- Transmitted with every search, browse, and tracking event
- Used to personalize results without any additional implementation
Headless integration
For headless storefronts or custom implementations, you must:- Collect relevant contextual information from your application
- Include it in the
contextparameter of your API requests - Manage user identity through the
identityparameter - Pass geographic location explicitly when making server-side API calls (the platform cannot automatically determine location from server IP addresses)
User identity
Layers uses three identifiers to track and personalize user experiences:Device ID (browser ID)
A persistent identifier stored in the browser’s local storage that remains constant across sessions. The device ID lets Layers recognize returning visitors even when they’re not signed in, for long-term personalization and behavior tracking. Source: Generated by the Storefront Pixel on first visit and persisted in browser storage.Session ID
A temporary identifier that represents a single browsing session. Layers-generated sessions use a rolling 30-minute inactivity window. The Storefront Pixel refreshes the window when a page loads and on every route change, including pages without tracked events. Legacy Shopify or fallback cookies remain preferred when present, and their lifetime is not controlled by Layers. Source: The Storefront Pixel’s Layers session cookie, or a sessionStorage/in-memory fallback when consent is unavailable.Customer ID
The Shopify customer ID for authenticated users. The customer ID is only present when a customer is signed in to their account. Source: Shopify customer ID, available whencustomer exists in Liquid templates.
The device ID, session ID, and customer ID are included in the identity parameter when making API requests. The Storefront Pixel handles this automatically for standard integrations.
See also
- Context Data Structure - Complete reference for geographic, cart, purchase history, marketing, customer profile, and custom context fields
- Usage & Privacy - How context influences search and privacy considerations
- Storefront Pixel - Automatic context collection
- Search API - Passing context in search requests
- Browse API - Passing context in browse requests