analyticsinterface
interface
Provides access to Shopify's customer event API
Anchor to propertiesProperties
- Anchor to subscribesubscribe(eventName: string, event_callback: Function) => Promise<undefined>
Analytics
- subscribe
(eventName: string, event_callback: Function) => Promise<undefined>
export interface Analytics {
subscribe?: (
eventName: string,
event_callback: Function,
) => Promise<undefined>;
}
Name
The name of the customer event
string
Was this section helpful?
Accessing Standard Api
import {register} from '@shopify/web-pixels-extension';
register(({analytics, browser, settings, init}) => {
analytics.subscribe('page_viewed', (event) => {
// subscribe to page_viewed events
});
analytics.subscribe('all_events', (event) => {
// subscribe to all events
});
analytics.subscribe('all_standard_events', (event) => {
// subscribe to all standard events
});
analytics.subscribe('all_custom_events', (event) => {
// subscribe to all custom events
});
});
examples
Accessing Standard Api
App Pixel
import {register} from '@shopify/web-pixels-extension'; register(({analytics, browser, settings, init}) => { analytics.subscribe('page_viewed', (event) => { // subscribe to page_viewed events }); analytics.subscribe('all_events', (event) => { // subscribe to all events }); analytics.subscribe('all_standard_events', (event) => { // subscribe to all standard events }); analytics.subscribe('all_custom_events', (event) => { // subscribe to all custom events }); });
Custom Pixel
analytics.subscribe('page_viewed', (event) => { // subscribe to page_viewed events }); analytics.subscribe('all_events', (event) => { // subscribe to all events }); analytics.subscribe('all_standard_events', (event) => { // subscribe to all standard events }); analytics.subscribe('all_custom_events', (event) => { // subscribe to all custom events });