Extra methods for the Google Tag Manager. Requires GTM to be included
Add named events to the list of possible event to be tracked, with the possibility of replacement tokens. Default tokens provided: - {{uri}}: Current pathname
events
events
Object
List of possible events and their config
[0]
String
The event type. Possible values are ga_event
, checkoutOption
, productClick
, productImpression
, raw
[1]
Object
The event data. Different for each type. View code for implemantation.
// Create named events
kafe.ext.googletagmanager.add({
'product-addedtocart': ['ga_event', {
category: 'Cart',
action: 'Product added - {{uri}}',
label: '{{productname}}',
value: '{{productvalue}}' // integer only
}],
'checkout-shipping': ['checkoutOption', {
step: 'Shipping method',
label: 'Shipped via {{method}}'
}],
'upsell-shown': ['productImpression', {
id: '{{sku}} - {{id}}',
name: '{{name}}',
brand: '{{productBrand}}',
price: '{{priceWithoutTaxes}}',
category: '{{category}} / {{subcategory}}',
position: '{{position}}',
list: 'Upsell products',
currency: 'CAD'
}],
'sunset-position': ['raw', {
foo: 'bar',
bar: 'foo'
}]
});
Push a event into the dataLayer
.
name
tokens
name
String
Event name
[tokens]
Object
Optional
List of replacement tokens
kafe.ext.googletagmanager.track('product-addedtocart', { productname: 'Sexy rainbow pants' });
kafe.ext.googletagmanager.track('upsell-shown', [
{
sku: '123',
price: 12.34,
name: 'Sexy rainbow pants'
},
{
sku: '456',
price: 45.67,
name: 'Plain beige skirt'
}
]);