I'm trying to make a custom report. I've just put some test code on my main page:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12323748-3']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar',
2, // This custom var is set to slot #1
'Test_var', // The name acts as a kind of category for the user activity
'Yes', // This value of the custom variable
2 // Sets the scope to session-level
]);
(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>
My custom report setup looks like this: http://updo.nl/file/ed351e11.png
However, it just comes up as empty (I let it gather data for 2 days before checking the report)
Any help would be appreciated
I've asked much the same question. I've been told that you have to put the setCustomVar line above the trackPageView line and below the var _gaq line. Like this:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12323748-3']);
_gaq.push(['_setCustomVar', 2, 'Test_var', 'Yes', 2]);
_gaq.push(['_trackPageview']);
_trackPageview sends all of the information to Google Analytics, so you can't add information after its already sent.