Skip to main content

Analytics API

The Analytics API lets you publish custom events and visitor information to web pixels configured on the store. Use this API to track customer behavior in your extension and send conversion data to third-party analytics services.

  • Track extension interactions: Publish custom events when customers interact with your extension, such as viewing a product recommendation or clicking a promotion banner.
  • Measure conversions: Send conversion events from customer account pages to analytics platforms for attribution and reporting.
  • Identify returning visitors: Submit visitor contact information so downstream analytics tools can associate sessions with known customers.
Support
Targets (24)

The shopify global object provides the analytics interface for customer account extensions. Access the following properties on shopify to publish custom events and send visitor data to web pixels.

Anchor to analytics
analytics
required

Tracks custom events and sends visitor information to web pixels. Use publish() to emit events and visitor() to submit visitor data.

Note

Requires connecting a third-party domain to Shopify for your customer account pages.


  • Publish events inside useEffect: Trigger analytics calls after the component mounts so you don't block the initial render.
  • Handle publish failures gracefully: Always attach a .catch() handler to shopify.analytics.publish() so undelivered events don't cause uncaught promise rejections.
  • Use descriptive event names: Choose event names that clearly identify the interaction, such as loyalty-points-redeemed or subscription-upgraded, so pixel consumers can filter and act on them.
  • Avoid sending sensitive data in event payloads: Don't include passwords, full payment details, or other personally identifiable information beyond what's needed for analytics.

  • Custom events published through this API are only delivered to web pixels that are configured on the store. If no pixels are active, the publish call resolves but has no downstream effect.
  • The shopify.analytics.visitor() method sends data to the store backend only. Visitor information isn't propagated to web pixels on the page.
  • Event payloads must be JSON-serializable. Functions, DOM nodes, and circular references can't be included.

Was this page helpful?