Advertisement
ju1ius

view_cart

Mar 4th, 2021 (edited)
1,852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.dataLayer = window.dataLayer || [];
  2. window.dataLayer.push({ ecommerce: null });  // Clear the previous ecommerce object
  3. window.dataLayer.push({
  4.   event: 'view_cart',           // name of the event. In this case, it always must be view_cart
  5.   ecommerce: {                         
  6.     items: [{                           // an array of all products currently in a cart
  7.       item_name: 'Product 1',           // insert an actual product name
  8.       item_id: 'product1',              // insert an actual product ID
  9.       price: '11.99',                   // insert an actual product price. Number or a string. Don't include currency code
  10.       item_brand: 'brand A',            // insert an actual product price
  11.       item_category: 'Apparel',         // insert an actual product top-level category
  12.       item_category2: 'T-shirt',        // if it is possible to drill down the categories (e.g. Apparel, then T-shirt, then Men), use item_category2, item_category3, etc. Can use from item_category up to item_category
  13.       quantity: '1'                     // product quantity
  14.     },{
  15.       item_name: 'Product 2',
  16.       item_id: 'product2',
  17.       price: '12.99',
  18.       item_brand: 'Brand B',
  19.       item_category: 'Category B',
  20.       item_variant: 'Yellow',
  21.       quantity: '1'
  22.     }]
  23.   }
  24. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement