eCommerce Transaction Data into Google Analytics

In BC we were able to push eCommerce transaction data into Google Analytics using code on the receipt page which called in the product data and then fed the individual product purchases into GA -

{module_data resource=“orders” version=“v3” fields=“id,shippingPrice,totalPrice” resourceId="{tag_orderid}" skip=“0” limit=“10” order=“id” collection=“trans”}
{module_data resource=“orders” version=“v3” fields=“itemId,productId,catalogueId,units,unitPrice,unitTaxRate,totalPrice,description,product” subresource=“products” resourceId="{tag_orderid}" skip=“0” limit=“10” order=“productId” collection=“products”}

Then we used -

ga(‘ecommerce:addTransaction’, {
‘id’: “{{ trans.id }}”,
‘affiliation’: ‘’,
‘revenue’: “{{ trans.totalPrice }}”,
‘shipping’: ‘{{ trans.shippingPrice }}’,
‘tax’: ‘0’
});

and

{% for prod in products.items -%}
{module_data resource=“catalogs” version=“v3” fields=“id,name” resourceId=“176691” skip=“0” limit=“10” order=“id” collection=“catalog”}
ga(‘ecommerce:addItem’, {
‘id’: “{{ trans.id }}”,
‘name’: “{{ prod.product.name }}”,
‘sku’: “{{ prod.product.productCode }}”,
‘category’: “{{ catalog.name }}”,
‘price’: “{{ prod.totalPrice }}”,
‘quantity’: ‘{{ prod.units }}’
});
{% endfor -%}

So I just want to check if this is going to be doable with Treepl using the equivalent liquid codes and if this could be added to the docs for partners to use like they had in BC.

Hi @SiroccoDigital
Will need someone from the team to confirm this but I am quite sure this will be very similar in Treepl. I can’t see why this shouldn’t be possible on the receipt page, since the data needed should be there to use in the Google code :slight_smile:

Hello @SiroccoDigital - Any luck with this one? I’ve been tasked with setting this up for an eCommerce client but am at a bit of a loss. Could you point me in the right direction if you’ve been able to crack it? Any help you can offer is much appreciated.

@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

@Peter-Schmidt - That’s great - should be able to work it out with your supplied example - much appreciated as always :grinning:

No worries @Craig :+1:

Thanks for the reply @Peter-Schmidt, this is what we have setup as well.

1 Like