You need to set _setCustomVar
before _trackPageview
. Otherwise, the data of the user variable is not associated (i.e., it is sent in the __utm.gif
tag and stored in cookies), and the custom variable is not monitored.
10% of visits that show user variables are most likely from pages that had other images (events, e-commerce, etc.) that carried user variable data. If you move _setCustomVar
to _trackPageview
(but after _setDomainName
), it should track 100%.
var _gaq = _gaq || []; _gaq.push(['_setAccount', '{{ GOOGLE_ANALYTICS_KEY }}']); _gaq.push(['_setDomainName', '.site.com']); _gaq.push(['_setCustomVar', 1, 'User Type', {% if user.is_authenticated %}'Registered User'{% else %}'Guest'{% endif %}, 2 ]); _gaq.push(['_trackPageview']); _gaq.push(['_trackPageLoadTime']);
Yahel source share