What context influences
Contextual information affects multiple aspects of the search experience: Relevance scoring: The platform adjusts relevance scores for products related to cart items or purchase history, surfacing complementary or similar items more prominently. Facet selection: Layers intelligently selects which facets (filters) to display based on the customer’s browsing context and previous interactions. Sort order optimization: Customer behavior patterns influence default sorting, showing more relevant products first. Geographic personalization: Layers applies location-aware merchandising rules and product availability based on the customer’s region. Intent understanding: Prior searches and click behavior inform how new queries are interpreted, improving semantic understanding over time. User affinities: When you pass contextual data along with anidentity, Layers derives affinity signals from cart contents, purchase history, and recently viewed products — such as preferred brands, product types, or variant options. Session-scoped signals like recently viewed products decay over time so that newer views influence ranking more than older ones. These signals include both promotions (boosting products that match detected preferences) and demotions (slightly suppressing non-matching products within the same attribute). Low-confidence signals are automatically filtered out so only meaningful affinities influence results. The computed affinities are returned in the _meta.affinities array of Search, Browse, and Blocks API responses. This lets you see which attributes influenced ranking for the current request.
Customer segmentation: Customer profile data (order history, spending patterns, loyalty status) enables personalized experiences for different customer segments.
Marketing attribution: UTM parameters and campaign information help track the effectiveness of marketing efforts and can influence product recommendations.
Channel-specific behavior: Shopping channel information enables different merchandising rules, sort orders, and analytics segmentation for web vs mobile app visitors.
Implementation notes
- Contextual information is processed in real-time; derived affinities are persisted per session to improve personalization across subsequent requests
- No personally identifiable information (PII) is required; all data is behavioral and anonymous
- Sort orders and merchandising rules always take precedence over contextual adjustments
- Missing or incomplete contextual data won’t break functionality; the platform gracefully degrades to non-personalized results
- For headless implementations, validate your contextual data structure matches the expected format to ensure proper personalization
Privacy considerations
The Layers platform is designed with privacy in mind:- Device IDs are anonymous browser identifiers, not tied to personal information
- Contextual data is used only for search personalization and is not shared with third parties
- Customer IDs are encrypted and handled according to Shopify’s privacy standards
- Geographic data is limited to city-level granularity, never precise coordinates
See also
- Contextual Information Overview - How contextual information works and user identity
- Context Data Structure - Complete reference for the context parameter
- Storefront Pixel - Automatic context collection
- Query Understanding - How context influences query interpretation
- Search API - Passing context in search requests
- Browse API - Passing context in browse requests