Analytics
2.6K members online now
2.6K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

2 sets of ecomm code in one domain

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I have 2 UA-xxxxxxx-1 codes in my website because I have one child website under my main website

i want to track my child website's ecomm stat to my child's Google analytics, but it seems like the stat will always go to my main site's analytics.

 

Please see the following for the codes, does anyone know what is going on? 

 

ps: my child site is called Apple

 

Regards

Jack

 

This is the Google ecomm code appear at the end of page

<script type="text/javascript">ga('ecommerce:addTransaction', {
'id': '149399',
'affiliation': 'Apple Embroidery Online Shop',
'revenue': '0.0000000000',
'shipping': '0.0000000000',
'tax': '0.0000000000', 
'city': 'Test', 
'state': 'Alabama', 
'country': 'United States' 
});
ga('ecommerce:addItem', {
'id': '149399',
'name': 'Layout Editor Add-on',
'sku': 'WHLE-01',
'category': 'Apple Product',
'price': '199.0000000000',
'quantity': '1'
});
ga('ecommerce:send');</script>

This is the Analytic Tracking code in the head tag

<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','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-aaaaaaa-1', 'auto');
  ga('create', 'UA-bbbbbbb-1', 'auto', 'Apple');
  ga('send', 'pageview');
  ga('Apple.send', 'pageview');
  ga('require', 'ecommerce');
  ga('Apple.require', 'ecommerce');

</script>

 

 

1 Expert replyverified_user

Re: 2 sets of ecomm code in one domain

Top Contributor
# 2
Top Contributor
Hi,

you would just need to duplicate the ecommerce part of the code if you want to send the ecommerce data to to both properties by adding Apple (or just leave the following if you want to collect ecommerce in the Apple property):
ga('Apple.ecommerce:addTransaction', {
'id': '149399',
'affiliation': 'Apple Embroidery Online Shop',
'revenue': '0.0000000000',
'shipping': '0.0000000000',
'tax': '0.0000000000',
'city': 'Test',
'state': 'Alabama',
'country': 'United States'
});
ga('Apple.ecommerce:addItem', {
'id': '149399',
'name': 'Layout Editor Add-on',
'sku': 'WHLE-01',
'category': 'Apple Product',
'price': '199.0000000000',
'quantity': '1'
});
ga('Apple.ecommerce:send');

Kind regards,
Zorin
Web analyst @ escapestudio.net