Following this guide to filter admin traffic in Google Analytics
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Excluding traffic by Cookie Content</title>
<meta name=.robots. content=.noindex. />
<!-- Google Analytics Code -->
<script type="text/javascript">// <![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']); //use real profile ID here
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
// ]]></script>
<!-- Google Analytics Code -->
</head>
<body onLoad="javascript:pageTracker._setVar('filter');">
<h1>Excluding traffic by Cookie Content</h1>
<p>This page will set a cookie in your browser that will help Google Analytics filter the traffic that comes from your computer when using this browser.</p>
<p>Once you have this setup, don't forget to set a filter in Google Analytics.</p>
<p>You will need to visit this page only once.</p>
<p>However, if you clear your browser cookies, reinstall the browser or operating system, make sure that you revisit this page, so the cookie will be set again.</p>
</body>
</html>
I get the error: pageTracker is not defined in Firebug. I hacked together a variation on this which gives no pageTracker error but I’m not sure that I’m doing this right.
<html>
<head>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);//use real profile ID here
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-XXXXXXX-X");//use real profile ID here
pageTracker._trackPageview();
pageTracker._setVar('founders');
} catch(err) {}
</script>
</head>
</html>
Is what I have above correct?
@mike was right, I was mixing techniques in the end I used Async, because it worked 😉
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-XXXXXXXX-X’]);
_gaq.push([‘_trackPageview’]);
_gaq.push([‘_setVar’,’trackme’]);
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga
.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘ht
tp://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.i
nsertBefore(ga, s);
})();