当我没有指定域名时,我的排除流量的cookie方法能够正常工作。现在我已经指定了域名,但它不再起作用。似乎会设置两个cookie,我创建的exclude.html页面会设置一个"mydomain.com"的cookie,而Google Analytics则会设置一个"www.mydomain.com"的cookie。
这是我exclude.html页面的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
我尝试添加了_gaq.push(['_setDomainName', 'www.mydomain.com']);
来使其工作,但似乎没有任何作用。这是我为所有其他页面设置的方式,使用的是www.mydomain.com。