Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- window.dataLayer = window.datalayer || [];
- dataLayer.push({
- 'ecommerce': {
- 'impressions': [
- {
- '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 ,
- 'brand': 'Signature',
- 'category': 'Blankets',
- 'variant': 'Plush',
- 'position': 1
- }]
- }
- });
- });
- <script>
- FOR MORE THAN ONE
- <script>
- var window.dataLayer = window.dataLayer || []
- //Step-1: Populate product in an array //
- var productImpressionArray = [
- {
- 'name': 'Plush Blue Blanket',
- 'product id': '12345',
- 'product code': '12345',
- 'price': '1115.25',
- 'currency': ZAR ,
- 'brand': 'Signature',
- 'category': 'Blankets',
- 'variant': 'Plush',
- 'position': 1
- },
- {
- 'name': 'Teksa Bedcover',
- 'product id': '6789',
- 'product code': '6789',
- 'price': '1299.11',
- 'currency': ZAR ,
- 'brand': 'HomeChoice',
- 'category': 'Bedding',
- 'variant': 'White',
- 'position': 2
- },
- ...................
- ]
- //Step - 2: Pass it in ecommerce object //
- var ecommerceObject = {
- 'ecommerce' : { 'impressions' : productImpressionArray },
- 'event' : 'productImpressions' //pass custom event
- }
- //Step - 3: Push to DataLayer//
- dataLayer.push(ecommerceObject)
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement