Stenor81

Checkout HC Enhanced Ecommerce

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