强制Google Analytics跟踪代码进入休眠状态

时间:2021-05-25 15:17:30

To use Google Analytics, you put some JavaScript code in your web page which will make an asynchronous request to Google when the page loads.

要使用Google Analytics,您需要在网页中添加一些JavaScript代码,这些代码会在页面加载时向Google发出异步请求。

From what I have read, this shouldn't block or slow down page load times if you include it directly before the end of your HTML Body. To verify this, I want to make the request after some period of time. The user should be able to log into my site regardless of the time it takes for the request to Google or if it comes back at all (the tracking code is on the login page).

根据我的阅读,如果您直接在HTML Body结束之前包含它,则不应阻止或减慢页面加载时间。为了验证这一点,我想在一段时间后提出请求。用户应该能够登录我的网站,无论是向Google发送请求所需的时间,还是根本不回来(跟踪代码都在登录页面上)。

There is a 'pageTracker._trackPageview()' function call in the Google Tracking code. Is this where the request is sent to Google?

Google跟踪代码中有一个'pageTracker._trackPageview()'函数调用。这是请求发送给Google的地方吗?

If so, should I just do:

如果是这样,我应该这样做:

window.setTimeout(pageTracker._trackPageview(), 5000);

any help is appreciated, especially if you have worked with Google Analytics and have this same problem.

任何帮助都表示赞赏,特别是如果您使用过谷歌分析并遇到同样的问题。

3 个解决方案

#1


1  

window.setTimeout(pageTracker._trackPageview(), 5000); will call the code immediately - what you want is

window.setTimeout(pageTracker._trackPageview(),5000);将立即调用代码 - 你想要的是什么

window.setTimeout(function() { pageTracker._trackPageview(); }, 5000);

window.setTimeout(function(){pageTracker._trackPageview();},5000);

#2


1  

This should work:

这应该工作:

window.setTimeout(pageTracker._trackPageview, 5000);

#3


0  

That should do it. Put some quotes around the call:

应该这样做。在电话会议上加上一些报价:

window.setTimeout("pageTracker._trackPageview()", 5000);

You can check this using Firebug if you want to see the request go through.

如果您想查看请求,可以使用Firebug进行检查。

#1


1  

window.setTimeout(pageTracker._trackPageview(), 5000); will call the code immediately - what you want is

window.setTimeout(pageTracker._trackPageview(),5000);将立即调用代码 - 你想要的是什么

window.setTimeout(function() { pageTracker._trackPageview(); }, 5000);

window.setTimeout(function(){pageTracker._trackPageview();},5000);

#2


1  

This should work:

这应该工作:

window.setTimeout(pageTracker._trackPageview, 5000);

#3


0  

That should do it. Put some quotes around the call:

应该这样做。在电话会议上加上一些报价:

window.setTimeout("pageTracker._trackPageview()", 5000);

You can check this using Firebug if you want to see the request go through.

如果您想查看请求,可以使用Firebug进行检查。