Skip to main content

page_viewed
interface

The page_viewed event logs an instance where a customer visited a page. This event is available on the online store, Checkout, Order status and Customer Account pages.

Note

Customer Accounts pages will only log the page_viewed event if a vanity domain is set up for the store.

string

The client-side ID of the customer, provided by Shopify

No additional data is provided by design. Use the event context to get the page metadata. E.g. event.context.document.location.href

string

The ID of the customer event

string

The name of the customer event

number

The sequence index number of the event.

string

The timestamp of when the customer event occurred, in ISO 8601 format

.Standard
Was this section helpful?

Accessing Standard Events

import {register} from '@shopify/web-pixels-extension';

register(({analytics}) => {
analytics.subscribe('page_viewed', (event) => {
// Example for accessing event data
const timeStamp = event.timestamp;

const pageEventId = event.id;

const payload = {
event_name: event.name,
event_data: {
pageEventId: pageEventId,
timeStamp: timeStamp,
},
};

// Example for sending event data to third party servers
fetch('https://example.com/pixel', {
method: 'POST',
body: JSON.stringify(payload),
keepalive: true,
});
});
});