Mobile app version of vmapp.org
Login or Join
Shelley277

: How do i properly use CustomVars in google analytics? How do i properly use custom vars in google analytics? I used the code below and here is what i notice i only seen 'one' being in the

@Shelley277

Posted in: #GoogleAnalytics #Javascript

How do i properly use custom vars in google analytics? I used the code below and here is what i notice


i only seen 'one' being in the get request
After 24 hours only 'one' showed up
After commenting out one and changing the 2 vars to use slotIndex-1 i notice NO vars going through GA


What am i doing wrong?

-edit again- Ok everything works. The problem is what i guessed in my answer. Then in firefox i accidentally used the profile which had cookies disabled so GA .gif wasnt being requested. In short the problem below was the string is too long or the value wasnt a string.

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);

if (cond) {
_gaq.push(['_setCustomVar',1, 'one', d1,1]);
_gaq.push(['_setCustomVar',2, 'name two', "sz",1]);
_gaq.push(['_setCustomVar',3, 'name3', boolVal,1]);
}
_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);
})();

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Shelley277

2 Comments

Sorted by latest first Latest Oldest Best

 

@Shelley277

I'm not 100% sure but


Bool Values are not allowed, only strings
You string may be too long thus not included


which may explain why neither are showing up.

10% popularity Vote Up Vote Down


 

@Sarah324

I would save a copy of the page locally to debug the Google Analytics scripts in this manner - look for Javascript syntax errors and calls to _gaq.push() which return an error.

There is most likely a problem with the values you are passing - a review of the _gaq Global Object documentation would suggest that you can find out (in real-time) the number of commands which failed to execute with the return of a _gaq.push() call - for example:

var pushErrors = _gaq.push(['_setCustomVar',2, 'name two', "sz",1]);
alert( 'Encountered ' + pushErrors + ' errors' );

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme