我在我网站的很多不同地方调用 _gaq.push(通过脚本、flash 等)。我还设置了自己的本地跟踪服务。与其在我当前代码的同一点调用我的服务,不如创建一个函数,在我每次调用 _gaq.push 时调用我的代码。
例如:
if(_gaq.push is called){
$.get('http://mydomain.com/tracking_pixel.gif');
}
最佳答案
在变量中捕获 _gaq.push
函数,然后用您自己的函数覆盖它,调用原始函数,然后调用您的代码。然后任何在你覆盖之后调用 _gaq.push
的东西都会同时调用。示例:
_gaq.basePush = _gaq.push; //capture the original
_gaq.push = function(/* params? */) { //override it
_gaq.basePush(/* params? */); //call the original
$.get('http://mydomain.com/tracking_pixel.gif'); //call your function
};
关于javascript - 连接到 _gaq.push - 谷歌分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7891488/