Advertisement
Stenor81

Impressions HC Enhanced Ecommerce

Dec 11th, 2019
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <script>
  2. window.dataLayer = window.datalayer || [];
  3.  
  4. dataLayer.push({
  5. 'ecommerce': {
  6. 'impressions': [
  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. 'brand': 'Signature',
  15. 'category': 'Blankets',
  16. 'variant': 'Plush',
  17. 'position': 1
  18. }]
  19. }
  20. });
  21.  
  22.  
  23. });
  24. <script>
  25.  
  26. FOR MORE THAN ONE
  27.  
  28. <script>
  29. var window.dataLayer = window.dataLayer || []
  30.  
  31. //Step-1: Populate product in an array //
  32. var productImpressionArray = [
  33. {
  34. 'name': 'Plush Blue Blanket',
  35. 'product id': '12345',
  36. 'product code': '12345',
  37. 'price': '1115.25',
  38. 'currency': ZAR ,
  39. 'brand': 'Signature',
  40. 'category': 'Blankets',
  41. 'variant': 'Plush',
  42. 'position': 1
  43. },
  44. {
  45. 'name': 'Teksa Bedcover',
  46. 'product id': '6789',
  47. 'product code': '6789',
  48. 'price': '1299.11',
  49. 'currency': ZAR ,
  50. 'brand': 'HomeChoice',
  51. 'category': 'Bedding',
  52. 'variant': 'White',
  53. 'position': 2
  54. },
  55. ...................
  56. ]
  57.  
  58. //Step - 2: Pass it in ecommerce object //
  59. var ecommerceObject = {
  60. 'ecommerce' : { 'impressions' : productImpressionArray },
  61. 'event' : 'productImpressions' //pass custom event
  62. }
  63.  
  64. //Step - 3: Push to DataLayer//
  65. dataLayer.push(ecommerceObject)
  66.  
  67. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement