Analytics
3.1K members online now
3.1K 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

Two Google Analytics Codes on same webpage

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

My client has a webpage with a Google Analytics code on it, but he can't give me Property level editing permison for some reason. He want me to put another Analytics code on webpage. Can i just create another GA account and put another Analytics code right under the existing code? Or this is not how it works?

 

Maybe somone knows the answer?

Thanks!

Two Google Analytics Codes on same webpage

Participant ✭ ☆ ☆
# 2
Participant ✭ ☆ ☆

Hi @Arturs T,

 

It is possible have multiple google analytics tracking on the website but you need to use a named tracker for the additional Google Analytics trackers in your GA tracking snippet.

 

For example:

 

ga('create', 'UA-111111-1', 'auto', 'myNamedTracker');
ga('create', 'UA-222222-2', 'auto');

ga('send', 'pageview');
ga('myNamedTracker.send', 'pageview');

 

 

I hope this helps to solve your issue.

Regards

Two Google Analytics Codes on same webpage

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi, thanks for your reply!

 

So bassically everything i need to do is chanche ga('create', 'UA-111111-1', 'auto', 'myNamedTracker'); this bold part of a code and then i can just put that code under the existing code? Is that right?

Two Google Analytics Codes on same webpage

[ Edited ]
Participant ✭ ☆ ☆
# 4
Participant ✭ ☆ ☆

You're welcome!

Yes, you need only one GA tracking snippet and you need to create an additional named tracker with your property id inside the snippet. Also, while you are sending hits, you need to specify your tracker name.

 

<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-111111-2', 'auto');

ga('create', 'UA-222222-1', 'auto', 'myNamedTracker');

ga('send', 'pageview');
ga('myNamedTracker.send', 'pageview');

 

</script>

 

Regards

Two Google Analytics Codes on same webpage

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

thank you for quick response!

 

Last questions - when i create my other GA account for that website, i do nothing different in that account, the only thing i need to do, is change Tracker name in GA snippet like you showed me? That Tracker name need to match something thats in my new account or it could be just a random name?

 

I'm not a programmer, so these things makes me confused! Smiley Very Happy

Two Google Analytics Codes on same webpage

Participant ✭ ☆ ☆
# 6
Participant ✭ ☆ ☆

Smiley Happy no worries.

 

You don't need to do any special setting on your Google Analytics account.  You just need your property id to use in the additional tracker. In your snippet, you do not need to change the current tracker but add a new one(Basically you need to add the lines that i marked bold to the current tracking snippet).

 

Name of the additional tracker is not important. You can name it however you want but please avoid using special characters ($%&/§#+ etc..) and don't start with a number just in case.

 

I hope this helps Smiley Happy

Regards

 

 

Two Google Analytics Codes on same webpage

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Thank you very much, you made my day a lot easier!

 

Your advice definately helped me, so now i hope i don't crush my clients website! Smiley Very Happy

 

Cheers!

Two Google Analytics Codes on same webpage

Participant ✭ ☆ ☆
# 8
Participant ✭ ☆ ☆

You're welcome! Happy to solve your problem! Smiley Happy

 

Just be careful Smiley Very Happy if you do what I explained you, nothing bad should happen.

 

Cheers!