Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 465
Sharethefun Avatar asked Mar 29 '26 00:03

Sharethefun


1 Answers

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.

like image 102
jk. Avatar answered Apr 03 '26 16:04

jk.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!