I have set up the _setCustomVar for my website, like this:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX']);
_gaq.push(['_setDomainName', '.blog4ever.com']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, 'B4E_Type_Pub', 'Silver_ou_Gold', 3]);
_gaq.push(['_setCustomVar', 2, 'B4E_Etat_Blog', 'normal', 3]);
(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>
In my dashboard, when I go in: Visitors -> Custom variables, I see my 2 variables but the numbers are really strange (like 40 pages views although I have many thousands pages views).
I have it installed for 2 days now.
Did somebody face the same problem?
You're lucky even 40 pageviews recorded these variables.
You need to call
_setCustomVar
before _trackPageview. Otherwise, the_trackPageview
call sends the data to Google Analytics, and only after that are the custom variables set. If you set the_setCustomVar
after the_trackPageview
, the custom variable data doesn't attach, and if no other__utm.gif
hits are set during that pageview, the data is basically gone forever.(Those 40 pageviews that recorded probably were tracked via some other on-page GA calls that are sending data after the pageview loads).