Using Goggle Analytics I’d like to use a custom variable. This is built in functionality, but unfortunately I don’t have control over the code that loads GA and calls _trackPageview;
This means I can’t call _setCustomVar before _trackPageview
If I call _trackPageview a second time will it log two page views?
For example
// I'm not able to change this order
_gaq.push(['_setAccount', 'UA-XXXXXXXX']);
_gaq.push(['_trackPageview']);
// I'm forced to run this after the first _trackPageview
_gaq.push(['_setCustomVar',1,'name','value']);
_gaq.push(['_trackPageview']);
Is there any other way to get the custom variable set
Yes, each _trackPageview will log a page view.
You could pass a pageURL to the second _trackPageview, and set a filter in your analytics profile to ignore those page views.
Alternatively, instead of a second _trackPageview, you could use _trackEvent to cause a tracking GIF request and deliver the custom variable.