How contextual information works
Contextual information is automatically collected and managed by the Storefront Pixel 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. This allows Layers to recognize returning visitors even when they’re not signed in, enabling 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. Sessions typically expire after a period of inactivity or when the user closes their browser (depending on Shopify’s session management). Source: Shopify session ID, available via Liquid template variables.Customer ID
The Shopify customer ID for authenticated users. This identifier is only present when a customer is signed in to their account. Source: Shopify customer ID, available whencustomer exists in Liquid templates.
These identifiers 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