Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

  1. i only seen 'one' being in the get request
  2. After 24 hours only 'one' showed up
  3. 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]); 

(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);
share|improve this question

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' );
share|improve this answer
all my push inc the error by 1. even "_gaq.push(['_setAccount', 'UA-12345678-1']);". Why? – acidzombie24 Nov 26 '10 at 23:03
Come to think of it. var _gaq = _gaq || []; is an array so it should give me the count of push. I'm still very confused. Also FF doesnt seem to GET the GIF but chrome does. There are no JS errors detected by both FF (firebug) and chrome (internal) or even IE8 but i cant tell if IE8 is requesting the img. Actually it looks like it is but the GET is significantly smaller then the others if i am getting that info properly – acidzombie24 Nov 26 '10 at 23:15
up vote 0 down vote accepted

I'm not 100% sure but

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

which may explain why neither are showing up.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.