Skip to main content

What context influences

Contextual information affects these parts of search: Relevance scoring: Layers adjusts relevance scores for products related to cart items or purchase history, surfacing complementary or similar items more prominently. Facet selection: Layers 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. 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 on each request
  • Personalization doesn’t require personally identifiable information (PII). Most context fields describe behavior, such as cart contents, viewed products, and prior searches. If you send a signed-in shopper’s Shopify customer ID in identity.customerId, Layers records it with that shopper’s search requests and analytics events (see Privacy considerations)
  • Sort orders and merchandising rules always take precedence over contextual adjustments
  • Missing or incomplete contextual data won’t break functionality; Layers falls back to non-personalized results
  • For headless implementations, check that your contextual data matches the expected format, or personalization may not apply

Privacy considerations

Layers handles contextual data as follows:
  • 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
  • Raw User-Agent strings are never recorded in analytics events. Layers derives a coarse device type (mobile, tablet, desktop, or bot) and records that instead
  • Analytics events record only the validated context fields described in the context data structure. Layers drops unrecognized keys before recording. Raw click identifiers (marketing.clickIds) are not recorded; only the derived clickSource is kept
  • URL query parameters recorded under custom.query are filtered before they are stored. Layers drops a parameter when its name looks like a credential or identifier (for example token, password, email, or a per-click ad ID such as gclid), when it is pagination or storefront state already modeled elsewhere (such as page, sort_by, or variant), or when its value looks sensitive (an email address, a signed token, a phone or tracking number, or a long random string). If every parameter on an event is filtered out, no custom.query data is recorded for that event
  • Customer IDs are Shopify’s numeric customer identifiers. They are stored encrypted at rest and in transit, pseudonymized before being sent to observability tooling, and visible in raw form to your dashboard users in search request logs, LayersQL, and MCP
  • Shopper location in context (context.geo) is limited to country, province, and city. Layers doesn’t derive coordinates from a shopper’s IP address
  • If your integration sends coordinates in a geo filter or distance sort, Layers uses them to filter or sort results for that request. Coordinates sent in a geo filter are also recorded with the request’s applied filters in search analytics

See also