Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在GA事件跟踪中使用自定义变量_Javascript_Jquery_Google Analytics_Event Tracking - Fatal编程技术网

Javascript 在GA事件跟踪中使用自定义变量

Javascript 在GA事件跟踪中使用自定义变量,javascript,jquery,google-analytics,event-tracking,Javascript,Jquery,Google Analytics,Event Tracking,我试图在动态模板系统中的一些事件跟踪中获得一个自定义变量。它使用URL中的信息作为变量 附加此脚本后,分析中不会出现任何问题。有人看到它有什么毛病吗 jQuery(function iCatGaFunction() { jQuery('#catbanner').click(function () { var url = jQuery(location).attr('href'); // get the current url var iCat = url.

我试图在动态模板系统中的一些事件跟踪中获得一个自定义变量。它使用URL中的信息作为变量

附加此脚本后,分析中不会出现任何问题。有人看到它有什么毛病吗

jQuery(function iCatGaFunction() {
    jQuery('#catbanner').click(function () {
        var url = jQuery(location).attr('href'); // get the current url
        var iCat = url.substring(url.lastIndexOf('/') + 1); // Last index of the url icat reference 
        _gaq.push(['_setCustomVar', 1, 'iCatBanner', iCat]); // GA snippet
    });
});

jQuery('#catbanner').find('a:first').attr('onClick', 'iCatGaFunction()'); // wrap first a href around <img> and call function onclick
我遵循了这里的说明-也许与范围有关?

我看到了自定义变量。我没有看到的是事件跟踪。setCustomVar后面必须跟一个交互命中,否则该值将不会被发送。@EikePierstorff-您能给我举个例子吗?你的意思是在iCat之后,在该方法内?或者在函数中使用一个单独的方法,就像这样_gaq.push[''u trackEvent','BannersTracking',//活动类别'itatbanner',//操作];无论如何,只要是在变量设置之后。在函数的末尾应该可以使用。@Eikepierstorf。。在分析中,我们现在得到了:事件动作=横幅-但没有事件标签??