Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- window.dataLayer = window.datalayer || [];
- dataLayer.push({
- 'ecommerce': {
- 'checkout': [
- {
- 'name': 'Plush Blue Blanket', // Name of product is required.
- 'colour': 'Blue',
- 'product code': '12345'
- 'product id': '12345', // Could be duplicate
- 'price': '1115.25',
- 'currency': ZAR
- 'shipping': 150
- 'tax": 175
- 'brand': 'Signature',
- 'category': 'Blankets',
- 'variant': 'Plush',
- 'totalValue': '1115.25',
- 'paymentType': 'terms',
- 'position': 1
- 'actionField : {step: 1}
- 'transactionId': 'HC12345'
- }]
- }
- });
- });
- <script>
- FOR MANY ITEMS
- <script>
- // Pass Purchased Products in array of object //
- var productPurchasedArray = [{
- {
- 'name': 'Plush Blue Blanket',
- 'product id': '12345',
- 'product code': '12345',
- 'price': '1115.25',
- 'quantity': 1
- 'currency': ZAR ,
- 'brand': 'Signature',
- 'category': 'Blankets',
- 'variant': 'Plush',
- 'position': 1
- },
- {
- 'name': 'Teksa Bedcover',
- 'product id': '6789',
- 'product code': '6789',
- 'price': '1299.11',
- 'quantity': 1
- 'currency': ZAR ,
- 'brand': 'HomeChoice',
- 'category': 'Bedding',
- 'variant': 'White',
- 'position': 2
- },
- var actionField = {
- 'transactionId': 'HC12345', // Transaction ID. Required for purchases
- 'currency': ZAR ,
- 'totalValue': '2949.01', // Total transaction value (incl. tax and shipping)
- 'tax':'384.65',
- 'shipping': '150',
- 'paymentType': 'terms',
- }
- //Push the product array data to the ecommerce 'purchase' object. //
- var ecommerceObject = {
- 'ecommerce' : {'purchase' : {
- 'products' : productPurchasedArray,
- 'actionField : actionField //.
- }},
- 'event' : 'transactionSuccess' //pass custom event
- }
- //Push the ecommerceObject data to dataLayer.//
- dataLayer.push(ecommerceObject)
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement