Reputation: 60614
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.
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).
There is a 'pageTracker._trackPageview()' function call in the Google Tracking code. Is this where the request is sent to 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.
Upvotes: 0
Views: 849
Reputation: 9888
This should work:
window.setTimeout(pageTracker._trackPageview, 5000);
Upvotes: 1
Reputation: 321766
window.setTimeout(pageTracker._trackPageview(), 5000);
will call the code immediately - what you want is
window.setTimeout(function() { pageTracker._trackPageview(); }, 5000);
Upvotes: 1
Reputation: 20950
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.
Upvotes: 0