Skip to content

Instantly share code, notes, and snippets.

@prabapro
Created March 25, 2020 07:04
Show Gist options
  • Save prabapro/45a78baa89f02b8c382d96dd15b40ed8 to your computer and use it in GitHub Desktop.
Save prabapro/45a78baa89f02b8c382d96dd15b40ed8 to your computer and use it in GitHub Desktop.
Data Layer
<script>
// Send transaction data with a pageview if available
// when the page loads. Otherwise, use an event when the transaction
// data becomes available.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'purchase', // MISSING EVENT NAME
'ecommerce': {
'purchase': {
'actionField': {
'id': 'T12345', // Transaction ID. Required for purchases and refunds. (best practice to match to backend order ID)
'affiliation': 'Dialog | HBB microsite', // use this to identify which portal or page drove the conversion
'revenue': '499.00', // Total transaction value (incl. tax and shipping)
'tax':'4.99', // include tax value if possible
'shipping': '0.00', // just leave as 0.00
},
'products': [{ // List of productFieldObjects.
'name': 'Unlimited Video Youtube + ViU', // The name of the product is required.
'id': '67890', // The SKU of the product. ID is required please try to link to billing system
'price': '499.00', // The value must not include anything else except number separated by a decimal point. Don’t use a comma as the separator, and don’t include any currency symbols.
'brand': 'HBB - Social Media Pack', // Dialog to confirm how to seperate prepaid | postpaid | HBB | internet card | social media packs | daily rentals | time based packs
//'category': 'HBB/Internet/socialMediaPack', //Product category of the item. Can have maximum five levels of hierarchy.
'quantity': 1, // Quantity is required as only one pack per purchase just default to 1
'metric1': 30, // Validity in days (hours should be in decimal (0.04167 days per hour))
'metric2': 1310, // anytime Data quota in Mb
'metric3': 135, // daytime Data quota  in Mb
'metric4': 135, // nightime Data quota in Mb
'metric5': 135 // Bonus Data Quota. if we have normal bonus and 4G bonus we are adding two together
}]
}
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment