Advertisement
prabapro

GTM - GA4_Items Custom JS Variable

Mar 9th, 2021
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function() {
  2.   var products = {{dlv -  purchase.products}};
  3.   return products.map(function(prod) {
  4.     return {
  5.       'item_name': prod.name,
  6.       'item_id': prod.id,
  7.       'price': prod.price,
  8.       'item_brand': prod.brand,
  9.       'item_category': prod.category.split('/')[0],
  10.       'item_category2': prod.category.split('/')[1],
  11.       'item_category3': prod.category.split('/')[2],
  12.       'item_category4': prod.category.split('/')[3],
  13.       'item_category5': prod.category.split('/')[4],
  14.       'item_variant': prod.variant,
  15.       'item_coupon': prod.coupon,
  16.       'quantity': prod.quantity
  17.     }
  18.   });
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement