我一直在使用主站点的代码跟踪主站点和子域,但是当我访问站点内容>页面时,它链接到主域名,当它应该链接到子域名对于应该引用该子域的查看页面。使用Google Analytics跟踪子域名
这是我的代码:
主要网站:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'xxxx']);
_gaq.push(['_setDomainName', 'sitename.com']);
_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);
})();
子域:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'xxxx']);
_gaq.push(['_setDomainName', 'sub.sitename.com']);
_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);
})();
我已阅读谷歌Analytics(分析)的子域文档。对于_setDomainName
我已尝试.sitename.com
和sitename.com
,但它仍显示相同的结果。因此,Google Analytics(分析)信息中心中的网页内容会链接到主网站,但是在引用子网页时,它不会链接到子网域。
这会对索引页面造成问题,因为我如何知道域和子域之间的唯一视图划分?我必须在这里做错事!
我有同样的问题。一种解决方案/解决方法是在所有请求的.htaccess中对index.html进行重写: http://stackoverflow.com/questions/10167755/append-index-html-to-root-directory 但是,这不是理想和为我工作,只因为我的主要领域是index.php和其他index.html。 另一个有趣的事情是,在Google Analytics中,您可以点击页面标题标签(即不是页面标签),然后区分它。同样,只有在子域名页面上有不同的页面标题! –
请参阅http://stackoverflow.com/questions/7033218/google-analytics-api-tracking-subdomains –