This question already has answers here:
Track campaigns with Google Analytics without query string parameters?
                                
                                    (9个答案)
                                
                        
                6年前关闭。
            
        

我正在测试Google Analytics(分析)广告系列跟踪。我的本地页面上有以下由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>


当我在启用了Google调试器的情况下单击Chrome中的链接时,跟踪信标就会触发,但不会显示正在传递的广告系列数据:

Campaign Count           : 1
Campaign Source          : (direct)
Campaign Medium          : (none);
Campaign Name            : (direct)


嗯,这令人沮丧。我想念什么?我们需要广告系列数据通过JavaScript而不是通过URL传递。

最佳答案

您可以在_set_trackPageview之前使用_setDomainName进行此操作。

_gaq.push(['_set', 'campaignParams', 'utm_campaign=CAMPAIGN&utm_source=SOURCE&utm_medium=MEDIUM']);

关于javascript - 广告系列数据未传递,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14072809/

10-12 06:03