eCommerce Transaction Data into Google Analytics

@Craig - Here are a couple of examples that we use. Hope this is helpful :slight_smile:

If you have your own snippet of code, I would think you just need to set up a for loop for multiple products. Hopefully you can use this :slight_smile:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GOOGLE-TAG"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-NWXXXXX');

gtag('event', 'purchase', {
  affiliation: 'NAME',
  currency: 'USD',
  items: [{
       {% for item in order.items %}
         'item_id': '{{item.sKUCode}}',
        'item_name': '{{item.Name}}',
        'item_price': '{{item.unitTotalPrice}}',
         'currency': 'USD',
        'item_brand': 'BRAND NAME',
        'item_category': 'CATEGORY',
        'quantity': {{item.quantity}}
      },
       {% endfor -%}
  ],
  transaction_id: {{order.Id}},
     'value': '{{order.totalPrice}}',
      'tax': '{{order.taxPrice}}',
      'shipping': '{{order.shippingOption.price}}.00'
})

</script>
1 Like