: Google Analytics multiple domains under one account while excluding one domain? Cross-post from Stackoverflow Here's the problem I am having: Currently, we need to track across www.chess.com and
Cross-post from Stackoverflow
Here's the problem I am having:
Currently, we need to track across chess.com and secure.chess.com. However, I cannot set the domain to .chess.com because the cookie causes some problems on another domain, live.chess.com.
So, to work around this, in code - I do something like this:
<? if (HTTPS) { ?>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-01']);
_gaq.push(['_setDomainName', 'secure.chess.com']);
_gaq.push(['_trackPageview']);
</script>
<? } else { ?>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-02']);
_gaq.push(['_setDomainName', 'www.chess.com']);
_gaq.push(['_trackPageview']);
</script>
<? } ?>
However, this forces us to maintain 2 analytics accounts (UA-XXXXX-01 and UA-XXXXX-02) and creates a separation between HTTPS and HTTP traffic.
How can I set this up so that ONE analytics account will track both secure.chess.com and chess.com without setting a top level cookie (.chess.com)?
More posts by @Cody1181609
1 Comments
Sorted by latest first Latest Oldest Best
<? if ( %%HTTP_HOST%% != 'live.chess.com' ) { ?>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-01']);
_gaq.push(['_setDomainName', '<? echo %%HTTP_HOST%% ?>']);
_gaq.push(['_trackPageview']);
</script>
<? } ?>
(Where %%HTTP_HOST%% is a variable generated by your server-side script)
Edit: To confirm, the following code is included on all pages generated at secure.chess.com and chess.com and no script errors display at secure.chess.com correct?
<script type="text/javascript">
(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>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.