Combining two Google Tracking codes in one HTML editor window

  • 1
  • Question
  • Updated 10 years ago
  • Answered
Can I combine the Google Tracking code from my main and subdomains in one HTML editor window? I would park the second code on the first blank line after the first code.

This would make it easier to insert the second code in my pages that lack it.

Thanks,
Bengo
Photo of Bengo

Bengo

  • 308 Posts
  • 3 Reply Likes
  • hot dogs, cake, pie

Posted 10 years ago

  • 1
Photo of jason

jason

  • 13 Posts
  • 5 Reply Likes
Hi

I have researched this and in theory yes it is possible to do this, but you would need to test it to see if it works for you:-

Your original code you would have put into the html widget would have looked somthing like this:-

<!--
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-XXXXXXX-1");
pageTracker._trackPageview();
</script>
-->

You would now add the 2nd analytic code as follows:-

<!--
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-XXXXXXX-1");
pageTracker._trackPageview();
var pageTracker2 = _gat._getTracker("UA-XXXXXXX-2");
pageTracker2._trackPageview();
</script>
-->

The problem however is that both domain and sub domain will be credited with a view so I am not sure how useful it then becomes.

You can get a lot more information by googling
"google tracking codes two codes on one page"