Skip to main content

Analytics API

The Analytics API provides methods to interact with Shopify's analytics framework. Use this API to publish custom events that are forwarded to all registered web pixels, or to submit visitor contact details directly to the shop backend.

Events published with publish() are forwarded only to web pixels. They aren't sent to the shop backend. Visitor data submitted with visitor() goes only to the shop backend. It isn't propagated to web pixels on the page.

  • Publish custom analytics events: Emit events from your extension that web pixels on the page can react to.
  • Submit visitor information: Send buyer contact details to the shop backend for attribution and analytics purposes.
  • Track extension-specific interactions: Publish events when buyers interact with your extension's UI to measure engagement.
Support
Targets (33)

Anchor to Properties and methodsProperties and methods

The shopify global object provides analytics capabilities for the current checkout. Access the following properties and methods on shopify to publish custom events and submit visitor data. Available to purchase extension targets.

Anchor to analytics
analytics
required

Tracks custom events and sends visitor information to Web Pixels. Use publish() to emit events and visitor() to submit buyer contact details.


  • Respect buyer privacy consent: Before publishing analytics events, check whether analytics processing is allowed using the Customer Privacy API. Read shopify.customerPrivacy.value.allowedProcessing.analytics and only publish events when it's true.
  • Use descriptive event names: When calling publish(), use specific event names that clearly describe the interaction (for example, "loyalty_points_redeemed" instead of "click"). This makes it easier for web pixel implementations to filter and process events.
  • Separate analytics from visitor data: Use publish() for events that web pixels should process and visitor() for contact details that should go to the shop backend. Don't use publish() to send visitor contact information.

Was this page helpful?