Skip to content

Instantly share code, notes, and snippets.

@hanafiah
Created January 14, 2016 07:01
Show Gist options
  • Save hanafiah/003c86cf8de7fb77f43e to your computer and use it in GitHub Desktop.
Save hanafiah/003c86cf8de7fb77f43e to your computer and use it in GitHub Desktop.
<script>
function beli() {
dataLayer.push({
'event': 'GTM.beli',
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345', // Transaction ID. Required for purchases and refunds.
'affiliation': 'Online Store',
'revenue': '35.43', // Total transaction value (incl. tax and shipping)
'tax':'4.90',
'shipping': '5.99',
'coupon': 'SUMMER_SALE'
},
'products': [{ // List of productFieldObjects.
'name': 'Triblend Android T-Shirt', // Name or ID is required.
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'quantity': 1,
'coupon': '' // Optional fields may be omitted or set to empty string.
},
{
'name': 'Donut Friday Scented T-Shirt',
'id': '67890',
'price': '33.75',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Black',
'quantity': 1
}]
}
}
});
}
beli();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment