Advertisement
Stenor81

Checkout Step 1 HC Enhanced Ecommerce

Dec 11th, 2019
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <script>
  2. window.dataLayer = window.datalayer || [];
  3.  
  4. dataLayer.push({
  5. 'ecommerce': {
  6. 'checkout': [
  7. {
  8. 'name': 'Plush Blue Blanket', // Name of product is required.
  9. 'colour': 'Blue',
  10. 'product code': '12345'
  11. 'product id': '12345', // Could be duplicate
  12. 'price': '1115.25',
  13. 'currency': ZAR
  14. 'shipping': 150
  15. 'tax": 175
  16. 'brand': 'Signature',
  17. 'category': 'Blankets',
  18. 'variant': 'Plush',
  19. 'totalValue': '1115.25',
  20. 'paymentType': 'terms',
  21. 'position': 1
  22. 'actionField : {step: 1}
  23. 'transactionId': 'HC12345'
  24. }]
  25. }
  26. });
  27.  
  28.  
  29. });
  30. <script>
  31.  
  32. FOR MANY ITEMS
  33.  
  34. <script>
  35. // Pass Purchased Products in array of object //
  36. var productPurchasedArray = [{
  37. {
  38. 'name': 'Plush Blue Blanket',
  39. 'product id': '12345',
  40. 'product code': '12345',
  41. 'price': '1115.25',
  42. 'quantity': 1
  43. 'currency': ZAR ,
  44. 'brand': 'Signature',
  45. 'category': 'Blankets',
  46. 'variant': 'Plush',
  47. 'position': 1
  48. },
  49. {
  50. 'name': 'Teksa Bedcover',
  51. 'product id': '6789',
  52. 'product code': '6789',
  53. 'price': '1299.11',
  54. 'quantity': 1
  55. 'currency': ZAR ,
  56. 'brand': 'HomeChoice',
  57. 'category': 'Bedding',
  58. 'variant': 'White',
  59. 'position': 2
  60. },
  61.  
  62. var actionField = {
  63. 'transactionId': 'HC12345', // Transaction ID. Required for purchases
  64. 'currency': ZAR ,
  65. 'totalValue': '2949.01', // Total transaction value (incl. tax and shipping)
  66. 'tax':'384.65',
  67. 'shipping': '150',
  68. 'paymentType': 'terms',
  69.  
  70. }
  71.  
  72.  
  73. //Push the product array data to the ecommerce 'purchase' object. //
  74. var ecommerceObject = {
  75. 'ecommerce' : {'purchase' : {
  76. 'products' : productPurchasedArray,
  77. 'actionField : actionField //.
  78. }},
  79. 'event' : 'transactionSuccess' //pass custom event
  80. }
  81.  
  82. //Push the ecommerceObject data to dataLayer.//
  83. dataLayer.push(ecommerceObject)
  84. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement