Skip to main content
deleted 19 characters in body
Source Link
user1585
user1585

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?

-edit2- I added my answer but i still dont have firefox requesting the image. Chrome looks like its doing it properly with opera and IE8 requesting very little.

-edit again- Additional noteOk everything works. This codeThe problem is at the end of my body inside ofwhat i guessed in my staticanswer. Then in firefox i accidentally used the profile which had cookies disabled so GA .js filegif wasnt being requested. WhichIn short the problem below was the string is included lasttoo long or 2nd lastthe 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);
})();

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?

-edit2- I added my answer but i still dont have firefox requesting the image. Chrome looks like its doing it properly with opera and IE8 requesting very little.

-edit- Additional note. This code is at the end of my body inside of my static .js file. Which is included last or 2nd last.

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);
})();

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]); 
}
_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);
})();
added 164 characters in body
Source Link
user1585
user1585

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?

-edit2- I added my answer but i still dont have firefox requesting the image. Chrome looks like its doing it properly with opera and IE8 requesting very little.

-edit- Additional note. This code is at the end of my body inside of my static .js file. Which is included last or 2nd last.

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);
})();

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- Additional note. This code is at the end of my body inside of my static .js file. Which is included last or 2nd last.

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);
})();

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?

-edit2- I added my answer but i still dont have firefox requesting the image. Chrome looks like its doing it properly with opera and IE8 requesting very little.

-edit- Additional note. This code is at the end of my body inside of my static .js file. Which is included last or 2nd last.

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);
})();
added 128 characters in body
Source Link
user1585
user1585

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- Additional note. This code is at the end of my body inside of my static .js file. Which is included last or 2nd last.

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);
})();

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?

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);
})();

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- Additional note. This code is at the end of my body inside of my static .js file. Which is included last or 2nd last.

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);
})();
Source Link
user1585
user1585
Loading