我正在测试 Google Analytics Campaign 跟踪。我的本地页面上有以下由 onclick 事件触发的 JavaScript 代码:
<script type="text/javascript">
function trackCampGoogle() {
try {
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_setCampNameKey', 'ga_campaign']); // name
_gaq.push(['_setCampMediumKey', 'ga_medium']); // medium
_gaq.push(['_setCampSourceKey', 'ga_source']); // source
_gaq.push(['_setCampTermKey', 'ga_term']); // term/keyword
_gaq.push(['_setCampContentKey', 'ga_content']); // content
_gaq.push(['_setCampNOKey', 'ga_nooverride']); // don't override
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_trackPageview','CampTrackerGoogle']);
setTimeout('document.location = "' + link.href + '"', 100);
}catch(err){}
}
</script>
当我在打开 GA 调试器的情况下单击 Chrome 中的链接时,跟踪信标会触发,但不显示正在传递的活动数据:
Campaign Count : 1
Campaign Source : (direct)
Campaign Medium : (none);
Campaign Name : (direct)
这,呃,令人沮丧。我错过了什么?我们需要通过 JavaScript 而不是在 URL 中传递活动数据。