Sharethefun
Sharethefun

Reputation: 824

Multiple Custom Variables on Google Analytics

I'm trying to test 6 custom variables on Google Analytics.

when I go to advanced segments, I can only see visits from the last variable. How can I make the rest custom variables work?

I didn't know if I had to put the _trackPageview more than one, so i try putting it after my fifth channel and it still didn't work.

Here is my code:

<script type="text/javascript">

var _gaq = _gaq || [];

_gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
_gaq.push(["_setCustomVar", 1, "Channel", "One", 3]); 
_gaq.push(["_setCustomVar", 1, "Channel", "Three", 1]); 
_gaq.push(["_setCustomVar", 1, "Channel", "Four", 1]); 
_gaq.push(["_setCustomVar", 1, "Channel", "Five", 2]); 
_gaq.push(['_trackPageview']);  
_gaq.push(["_setCustomVar", 1, "Channel", "Six", 2]);
 _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);

  })();

</script>

Can someone help me with this?

How can I get more than one custom variables to work?

Thank you SO!

Upvotes: 3

Views: 3595

Answers (1)

jk.
jk.

Reputation: 14435

There is a limit of 5 custom variables per request.

Duplicate key names cannot be used across slots. Channel vars are all in slot 1.

The custom variable with the key name of "Channel" is overwritten by the last custom variable. To illustrate, consider this:

_gaq.push(["_setCustomVar", 1, "Visitor-Type", "Member", 1]);
_gaq.push(["_setCustomVar", 1, "Visitor-Type", "Non-Member", 1]);

The custom variable of Visitor-Type will be recorded as Non-member as it overrides the previous custom variable. It will not record a value for both in analytics.

You could try this instead:

_gaq.push(["_setCustomVar", 1, "Channel", "One", 3]); 
_gaq.push(["_setCustomVar", 2, "Channel", "Two", 1]); 
_gaq.push(["_setCustomVar", 3, "Channel", "Three", 1]); 
_gaq.push(["_setCustomVar", 4, "Channel", "Four", 1]); 
_gaq.push(["_setCustomVar", 5, "Channel", "Five", 2]);

See Custom Variable Usage Guidelines.

Or, use Event Tracking instead of some or all of these custom vars.

Upvotes: 8

Related Questions