The problem with Google Analytics _setCustomVar

I am trying to set a custom variable in my Google Analytics tracking for a very crude form of testing split.

The code that I use at the end of the head section is

var _gaq = _gaq || []; _gaq.push( ['_setAccount', 'UA-xxxxxx-xx'], ['_setCustomVar', 1, 'split', '1', 2], ['_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); })(); 

The page view is perfectly tracked, but I see nothing but "(not set)" in the "Custom section" in the "Visitors" section.

Can someone notice something wrong? I had this work before using old ga.js before asynchronous stuff came up.

Thanks.

+4
source share
1 answer

_SetCustomVar data is displayed in the Visitors Custom Variables report. Only data from _setVar is displayed in the "User Defined" report.

+7
source

Source: https://habr.com/ru/post/1315941/


All Articles