--- title: Analytics API description: >- 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. api_version: 2026-04 api_name: customer-account-ui-extensions source_url: html: >- https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/analytics-api md: >- https://shopify.dev/docs/api/customer-account-ui-extensions/latest/target-apis/platform-apis/analytics-api.md --- # Analytics API The Analytics API lets you publish custom events and visitor information to [web pixels](https://shopify.dev/docs/api/web-pixels-api) configured on the store. Use this API to track customer behavior in your extension and send conversion data to third-party analytics services. ### Use cases * **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) ### Supported targets * [customer-account.​footer.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/footer#footer-render-after-) * [customer-account.​order-index.​announcement.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-actions#order-index-announcement-) * [customer-account.​order-index.​block.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-actions#order-index-block-) * [customer-account.​order-status.​announcement.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#order-status-announcement-) * [customer-account.​order-status.​block.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#order-status-block-) * [customer-account.​order-status.​cart-line-item.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#cart-line-item-render-after-) * [customer-account.​order-status.​cart-line-list.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#cart-line-list-render-after-) * [customer-account.​order-status.​customer-information.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-status#customer-information-render-after-) * [customer-account.​order-status.​fulfillment-details.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/fulfillment-status#fulfillment-status-targets) * [customer-account.​order-status.​payment-details.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/payments-and-returns#payments-and-returns-targets) * [customer-account.​order-status.​return-details.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/payments-and-returns#return-details-render-after-) * [customer-account.​order-status.​unfulfilled-items.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/fulfillment-status#unfulfilled-items-render-after-) * [customer-account.​order.​action.​menu-item.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-actions#order-action-menu-item-) * [customer-account.​order.​action.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/order-actions#order-action-) * [customer-account.​order.​page.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/full-page#order-specific-full-page-) * [customer-account.​page.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/full-page#customer-account-full-page-) * [customer-account.​profile.​addresses.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-default#profile-page-default-targets-) * [customer-account.​profile.​announcement.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-default#profile-announcement-) * [customer-account.​profile.​block.​render](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-default#profile-block-) * [customer-account.​profile.​company-details.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-b2b#profile-page-b2b-targets-) * [customer-account.​profile.​company-location-addresses.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-b2b#company-location-addresses-render-after-) * [customer-account.​profile.​company-location-payment.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-b2b#company-location-payment-render-after-) * [customer-account.​profile.​company-location-staff.​render-after](https://shopify.dev/docs/api/customer-account-ui-extensions/2026-04/targets/profile-page-b2b#company-location-staff-render-after-) * customer-account.​profile.​payment.​render-after ### Properties The [`shopify` global object](https://shopify.dev/docs/api/customer-account-ui-extensions/latest#target-apis-define-what-your-extension-does) 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. * **analytics** **Analytics** **required** Tracks custom events and sends visitor information to [web pixels](https://shopify.dev/docs/apps/build/marketing-analytics/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. ### Analytics Tracks custom events and sends visitor information to \[Web Pixels]\(/docs/apps/marketing). Use \`publish()\` to emit events and \`visitor()\` to submit buyer contact details. * publish Publishes a custom event to \[Web Pixels]\(/docs/apps/marketing). Returns \`true\` when the event is successfully dispatched. The Promise resolves to \`true\` when the event was dispatched. The boolean indicates dispatch confirmation only. It doesn't indicate whether any specific web pixel processed the event. ```ts (name: string, data: Record) => Promise ``` * visitor Submits buyer contact details for attribution and analytics purposes. ```ts (data: { email?: string; phone?: string; }) => Promise ``` ### VisitorResult Represents a visitor result. ```ts VisitorSuccess | VisitorError ``` ### VisitorSuccess Represents a successful visitor result. * type Indicates that the visitor information was validated and submitted. ```ts 'success' ``` ### VisitorError Represents an unsuccessful visitor result. * message A message that explains the error. This message is useful for debugging. It isn't localized and shouldn't be displayed to the buyer. ```ts string ``` * type Indicates that the visitor information is invalid and wasn't submitted. Common causes include using the wrong data type or omitting a required property. ```ts 'error' ``` Examples ### Examples * #### ##### Description Publish a custom event to all web pixels configured on the store. This example fires a \`customer-account-extension-loaded\` event when the extension mounts and logs whether the publish succeeded. ##### jsx ```tsx import '@shopify/ui-extensions/preact'; import {render} from 'preact'; import {useEffect} from 'preact/hooks'; export default async () => { render(, document.body); }; function Extension() { useEffect(() => { shopify.analytics .publish( 'customer-account-extension-loaded', { extensionName: 'My Extension', }, ) .then((result) => { if (result) { console.log( 'successfully published event, web pixels can now receive this event', ); } else { console.log('failed to publish event'); } }) .catch((error) => { console.log('failed to publish event'); console.log('error', error); }); }, []); return ( See console for result ); } ``` * #### ##### Description Send visitor contact details to the store backend for identity resolution. This example submits an email and phone number using \`shopify.analytics.visitor()\` and handles the success or error response. ##### jsx ```tsx import '@shopify/ui-extensions/preact'; import {render} from 'preact'; import {useEffect} from 'preact/hooks'; export default async () => { render(, document.body); }; function Extension() { useEffect(() => { shopify.analytics .visitor({ email: 'someEmail@example.com', phone: '+1 555 555 5555', }) .then((result) => { if (result.type === 'success') { console.log('Success', result); } else { console.error('Error', result); } }); }, []); return ( See console for result ); } ``` *** ## Best practices * **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. *** ## Limitations * 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. ***