views:

183

answers:

1

i am using the vanilla ga asynchronous code thusly, right before end of </head>:

<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxx-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);
})();
</script>
</head>

now, later in the middle of the page i call:

<script>
_gaq.push(['_setCustomVar',
  1,
  'usertype',
  'anon',
  2
]);
</script>

the question is, do i need to make another call to _trackPageView?

that is, should i add another

_gaq.push(['_trackPageview']);

...?

A: 

Yes, you will need to make another call to _trackPageView in order to count the _setCustomVar. However, this will count as 2 separate page views, which is going to inflate the # of page views for the page. So you should instead move the _setCustomVar up to before _trackPageView is called.

Crayon Violent
thank you crayon violent, perfect answer!
duggi