Analytics
4.7K members online now
4.7K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Google analytics wont send data to 2 properties, no matter how I tweak the code

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Here's what I've tried:

<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-00000000-5', {'allowAnchor': true});
ga('send', 'pageview');
ga('create', 'UA-00000000-2', {'allowAnchor': true});
ga('b.send', 'pageview');
</script>

<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-00000000-5', {'allowAnchor': true}, 'domain.com');
ga('create', 'UA-00000000-2', {'allowAnchor': true}, {'name':'b'});
ga('send', 'pageview');
ga('b.send', 'pageview');
</script>

<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-00000000-5', {'allowAnchor': true}, 'domain.com');
ga('send', 'pageview');
ga('create', 'UA-00000000-2', {'allowAnchor': true}, {'name':'b'});
ga('b.send', 'pageview');
</script>

I've also tried putting each set of code in separate files and including them that way, but no matter what I do, it only sends to whichever property is mentioned first (in this case UA-00000000-5, but if I switch the order it sends to -2 and ignores -5).

 

How do I get Google Analytics to send to two properties at once?

1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Stone E
March 2017

Google analytics wont send data to 2 properties, no matter how I tweak the code

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

I found the solution.

 

I just needed to change:

 

ga('create', 'UA-00000000-2', {'allowAnchor': true}, {'name':'b'});

 

to

 

ga('create', 'UA-00000000-2', {'allowAnchor': true, 'name':'b'});

View solution in original post

Google analytics wont send data to 2 properties, no matter how I tweak the code

A T
Participant ✭ ✭ ✭
# 2
A T
Participant ✭ ✭ ✭

details: https://www.optimizesmart.com/using-multiple-trackers-for-cross-domain-tracking-in-universal-analyti...

 

follow the syntax as it is:

 

ga('create', 'UA-00000000-2',{'name':'b'});

ga('b.send', 'pageview');
Marked as Best Answer.
Solution
Accepted by topic author Stone E
March 2017

Google analytics wont send data to 2 properties, no matter how I tweak the code

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

I found the solution.

 

I just needed to change:

 

ga('create', 'UA-00000000-2', {'allowAnchor': true}, {'name':'b'});

 

to

 

ga('create', 'UA-00000000-2', {'allowAnchor': true, 'name':'b'});