10

What are the implications of having two tracking codes on 1 site? Both codes will be right under neath one another

e.g.

<script type="text/javascript">// <![CDATA[
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-account-1']);
  _gaq.push(['_setDomainName', 'mydomain']);
  _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>

and

<script type="text/javascript">// <![CDATA[
var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-account-2']);
  _gaq.push(['_setDomainName', 'mydomain']);
  _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>
9

Google allows Multiple tracking codes on web pages however some configs may not be supported.

You can install multiple instances of the Google Analytics tracking code on your web pages to send data to multiple properties in your account.

Not all configurations are supported. You can, for example, install multiple instances of the Universal Analytics tracking code (analytics.js) on your web pages but only one instance of the Classic Analytics code (ga.js). Multiple instances of ga.js might result in inaccurate data collection, processing, or reporting. You can, however, install one or more instances of analytics.js on web pages that also have a single instance of ga.js.

Using multiple tracking codes might be useful if users with access to different properties need to see data from the same web site, or if you have multiple versions of a web site. You might, for example, want to collect data from example.com using one instance of analytics.js, collect data from example.co.uk in another instance of analytics.js, and use a third instance of analytics.js on both websites to see the aggregate data.

Using Multiple Tracking Objects you can combined multiple Google Analytics ID's and accounts, this is useful for multiple site owners overseeing all of parts of the website. This can be done by editing the JavaScript see the example below:

ga('create', 'UA-XXXX-Y', 'auto');
ga('create', 'UA-12345-6', 'auto', 'newTracker');  // New tracker.
1

There will be no implications, but i would rather suggest that instead of doing this, you create a separate view on one analytics and give access to whomever you need to give, if that is the reason. Also, depending on your business of course, if tracking is important to you (which looks like it is). I would encourage you to use Google Tag Manager in order to add some events, since with this set-up you will get a lot of info, but those info's might be misleading since GA (without configuration and events and other stuff) will collect data that might look ... (not true) to you. With GTM you will get more control over your tracking code, you will not mess up your code, you will have less js. on your site, and most importantly you will get more accurate data in your GA account. Cheers

0

Locally hosting the analytics.js code is in 99.9% of cases unnecessary, and more hassle than it’s worth in my opinion. Clever developers like to experiment, and some consider it a good idea to locally host the Google Analytics code on their own server for faster delivery, speeding up website rendering in a browser window. Google doesn’t recommend it and either do I.

Not the answer you're looking for? Browse other questions tagged or ask your own question.