Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// if you have analytics, set them in pagevisibility mode to get real-user-trackig according to prerender-issues in Chrome/WebKit.
var viewCounted = false;
function handleVisibilityChange(evt) {
//Only count the view once we're done prerendering AND the document is done loading
if (document.webkitVisibilityState == 'prerender'
|| document.readyState != 'complete' || viewCounted)
/* Implementation of view counting system starts here */
// Code for Google Analytics | Change UA-XXXXX-X to be your site's ID
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview'],['_trackPageLoadTime']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
/* Implementation of view counting system ends here */
viewCounted = true;
//We'll call checkCountView on load no matter what.
window.addEventListener('load', handleVisibilityChange, false);
if (document.webkitVisibilityState == 'prerender') {
document.addEventListener('webkitvisibilitychange', handleVisibilityChange, false);

This comment has been minimized.


This comment has been minimized.

Copy link
Owner Author

anselmh commented Aug 3, 2011

This is obsolete since yesterday: now included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.