The page method lets you send custom page tracking events to all of your installed apps.
stackpile.analytics.page(name, [data], [settings], callback);
Parameter | Required | Description |
---|---|---|
name |
Yes | This is the name of the page you'd like to track. This is a required parameter. |
data |
No | An object containing the custom data you would like to send with the page tracking event. Data can be sent to all installed apps, or individual apps, for example mixpanel or heap . See examples below for more info. |
settings |
No | An object containing Stackpile specific options. Currently only supports timeout and only . Use the timeout setting to set the timeout duration before the callback function is called. If you only need to send an event to specific apps in your stack, use the only setting. For example: only: ['mixpanel', 'keenio'] |
callback |
No | A function that is called after the set timeout . Can be used if you need to wait before continuing with a process on your page. |
A few examples of how you can use page
to send custom data to your installed apps:
stackpile.analytics.page('product_detail', {
all: {
category: 'Kitchen',
sku: '3278'
},
optimizely: {
price: 6999
}
});
This will send page: "product_detail"
with custom properties set for category
and sku
to all installed apps that support page tracking and price: 6999
to Optimizely.
You can use the following custom data properties to send data to selected apps:
Property | App |
---|---|
all |
All installed apps |
googleanalytics |
Google Analytics |
optimizely |
Optimizely |
{primary} Currently we only support the page event for Google Analytics and Optimizely.
We are in the process of enabling this for other integrations as well.
Because our scripts are loaded asynchronous, you could run into an issue when trying to send page events as soon as the page loads if the API is not ready yet. The onReady
event is a callback function that lets you know when the Stackpile Unified Analytics API is ready.
(_stackpile = window._stackpile || []).push(['onReady', onSPReady]);
function onSPReady() {
// Code that will be fired as soon as
// the API is ready. For example:
stackpile.analytics.page('product_detail');
}