How to track Ecommerce for 2 GA accounts?

Highlighted
New Member
1 0 1

I added 1 GA via sjopify integration. I need send transaction information to one more GA account.

 

I had code that I was using previously but it is not helping me anymore:

 

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');


ga('create', 'UA-***', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['domain.com'] );
ga('send', 'pageview');

ga('require', 'ecommerce', 'ecommerce.js')

var checkoutObj = window.Shopify.checkout,
lineItems = checkoutObj.line_items

if (checkoutObj)
// I'm using the checkout object to pull order-wide data.
// (you can find other available params in the Shopify JS API)
ga('ecommerce:addTransaction', {
'id': {{ order.order_number }},
'affiliation': '',
'revenue': {{ checkout.total_price | money_without_currency }},
'shipping': {{ shipping_method.price | money_without_currency }},
'tax': {{ tax_line.price | money_without_currency }}
})

if (lineItems)
for (var i = 0; i < lineItems.length; i++){
var line_item = lineItems[i]
// and I'm using the lineItem objects to get individual item data
// (you can find other available params in the Shopify JS API)
ga('ecommerce:addItem', {
'id': line_item.product_id,
'name': line_item.title,
'sku': line_item.sku,
'category': '',
'price': line_item.price,
'quantity': line_item.quantity
});
}

// ayy, send the data we we're trying to get!
ga('ecommerce:send');
ga('send', 'event', 'Ecommerce Amienaturals', 'Purchase')

</script>

1 Like