1

I am using Google Analytics Custom Variables for a site I am working on. Here is the code snippet uploaded on the page.

   _gaq.push(['_setAccount', 'UA-xxxxxxxxx-1']);
 //]]>
 </script>

 <script>
  //<![CDATA[
    _gaq.push(['_trackPageview', 'searches/new/registration/complete']);
    _gaq.push(['_setCustomVar', 1, "member type", "registered", 1]);
    _gaq.push(['_trackEvent', 'registration', 'signup',,1]);

Although I am aware that the _trackPageview needs to be placed after the _setCustomVar call, I am still seeing numbers flow through into Google Analytics as 'member type=registered'. I do not want to dismiss these numbers and I want to make some sense of it before I amend this error in how the snippet was placed.

Any reason why I stil received visits for this Name-Value combination?

Thanks -

  • This is not a question about programming but a question about GA usage. You should post this to Webmasters SE instead – Eduardo Feb 22 '12 at 06:49

2 Answers2

0

Because your custom variable's scope is set to 1, it'll still get fired by "trackEvent" (even without "trackPageview".

If your scope was set to 3 (page-level), it will then rely on "trackPageview" and will not register well with "trackEvent"

George
  • 6,006
  • 6
  • 48
  • 68
0

The Custom Var is set with a GA cookie, and is actually stored and sent on your next _trackPageview, that's why you can still see it, all you are doing to sending the data probably in a moment you don't want to (the next pageview).

Edit: Also as pointed out, it could go with your _trackEvent method, wich will end up doing the same thing, sending the data in a particular time you dont intent to, specially with events, wich are linked to interactions, so if no one triggers those in the page you are trying to set the customVar, it wont get set at all.

Augusto Roselli
  • 220
  • 1
  • 4
  • 1
    This is only true for Visitor level custom variables like the OP is using; session and page-level custom variables don't get stored in the cookie. But, what's actually happening here is that the custom variable will get set when you call `_trackEvent` on that page. – Yahel Feb 22 '12 at 13:33