By jonr on
My Subject line isn't very clear, but here is my setup:
I have one drupal instance running on my server. I have two domains pointing to the instance. These domains have two different databases for almost everything, only part of them are shared.
I have set up the Analytics javascript code inside the page-front.tpl.php and page.tpl.php, not pretty but I thought it would work:
<?php
if( substr_count($_SERVER['HTTP_HOST'],'thathostname.com') > 0 )
$googletrackid = "UA-XXXX-1";
else
$googletrackid = "UA-XXXX-2";
?>
<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">
try {
var pageTracker = _gat._getTracker("<?php echo $googletrackid ?>");
pageTracker._trackPageview();
} catch(err) {}</script>
But when I look at the reports, I see mixed up URLs, URLs from the one site show up as part of the other site and vice versa. The url do throw a 404 when I test them. What could I be doing wrong? Is it possible that my php code is cached in some way, perhaps?
Comments
If you use
If you use http://drupal.org/project/google_analytics you can easily set up different Google Analytics accounts for the two different sites/databases.