Transactions
Tracking transactions lets you use features such as eCommerce analytics, product purchase segmentation, or cart/transaction based automations.
Authentication
Requests to the SDK may require customer authentication. For more details, see this article.
Using Google Data Layer
If you use Google Data Layer, you can connect it with Synerise.
To track transactions, you need to use Universal Analytics enhanced e-commerce or Google Analytics 4 e-commerce.
SR.init({
"trackerKey":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"dataLayer":dataLayer,
"gaVersion": "CHOOSE_VERSION"
});
The gaVersion
parameter is used to set the Google Analytics version.
- If you only use one GA version on your website, you don’t need to add this parameter.
- To send events to Universal Analytics, set the value to
UA
- To send events to Google Analytics 4, set the value to
GA4
This solution lets you track events such as the following:
Product added to shopping cart
dataLayer.push({
'event': 'addToCart',
'ecommerce': {
'currencyCode': 'EUR',
'add': {
'products': [{
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1
}]
}
}
})
Product removed from shopping cart
dataLayer.push({
'event': 'removeFromCart',
'ecommerce': {
'remove': {
'products': [{
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1
}]
}
}
})
Purchase details
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345',
'affiliation': 'Online Store',
'revenue': '35.43',
'tax': '4.90',
'shipping': '5.99',
'coupon': 'SUMMER_SALE'
},
'products': [{
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1,
'coupon': ''
},
{
'name': 'Donut Friday Scented T-Shirt',
'id': '67890',
'price': '33.75',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Black',
'quantity': 1
}
]
}
}
})
Tracking transactions without Google Data Layer
If you’re not integrated with Google Data Layer, you can create your own array variable and connect it to Synerise using the SDK:
SR.init({
"trackerKey":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"dataLayer": window["syneriseLayer"] = []
});
After this configuration, you can send objects like the ones above to the syneriseLayer
variable instead of the dataLayer
variable:
syneriseLayer.push({...})