views:

50

answers:

0

I got the cookie method of excluding my traffic to work when I didn't specify the domain. Now that I have specified the domain, it no longer works. It appears to be setting two cookies, the exclude.html page I created is setting a cookie of "mydomain.com" and the google analytics is setting a cookie of "www.mydomain.com".

Here is the code for my exclude.html page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Exclude Me</title>
    <script type="text/javascript">

        var _gaq = _gaq || [];
        _gaq.push(['_setVar', 'exclude_me']);
        _gaq.push(['_setDomainName', 'www.mydomain.com']);
        _gaq.push(['_setAccount', 'UA-xxxxxxxx-x']);
        _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>
</head>
<body>
    <p>
        This computer now has a cookie placed on it to exclude it from any Google Analytics reports.</p>
    <p>
        If you delete your cookies, you will need to revisit/reload this page again.</p>
</body>
</html>

I added the _gaq.push(['_setDomainName', 'www.mydomain.com']); to try and get it to work which doesn't appear to be doing anything. That is the way I have it setup for all the other pages, using the www.mydomain.com.