Reputation: 245
as the title says, how do I track a website with Google Analystics from two different accounts?
I made some research about this topic and found alot of old posts which were saying that you should include the different tracking codes at each side. But this can't be the best way, right?
Is it possible to do something like this?
Old Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
New Code:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_setAccount', 'UA-xxxxxxxx-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Thanks in advance Jack
Upvotes: 0
Views: 614
Reputation: 27614
Yes, its possible without updating any old code. you have to add other account to primary account:
Click Admin at the top of Google Analytic page.
To show three column Account, PROPERTY, VIEW.
Select USER MANAGEMENT from Account, PROPERTY, VIEW base on access permission.
Enter Email address and assign roll.
check your secondary email address website tracking same as primary email address.
Upvotes: 1
Reputation: 1421
You can track the same page on two different GA accounts using this code:
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-12345678-1'], // First account
['_trackPageview'],
['b._setAccount', 'UA-87654321-1'], // Second account
['b._trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
This has always worked for us.
Upvotes: 1