Re:ABalytics.js: Client-side A/B Testing With Google Analytics
by danmaz74 on Wednesday October 10, 2012 @05:11PM
(#4638205)
Concat is only called before GA is loaded, so I don't think any race condition could happen.
[ Parent
| on HN ]
Re:ABalytics.js: Client-side A/B Testing With Google Analytics
by yahelc on Wednesday October 10, 2012 @05:47PM
(#4638376)
Only if everyone loads it the same way. But there are lots of different ways to load GA; the only reason _gaq.push() isn't scary and doesn't raise the specter of race conditions is because of the 'spoofing' GA does.
There are LOTS of different versions of the GA snippet floating around the internet; the assumptions this configuration makes would only work for some of them.
For example, some people load GA like this:
<script async src="//google-analytics.com/ga.js"> </script>
<script>
var _gaq = _gaq || [];
...
</script>
Folks who do this will break at minimum with older browsers that don't support async; not sure what it would do with async support, though.It seems unnecessarily risky.
Re:ABalytics.js: Client-side A/B Testing With Google Analytics
by danmaz74 on Wednesday October 10, 2012 @06:03PM
(#4638437)
Ok, now I understand what the issue is. I guess a good solution would be to pass _gaq to my library initializer and push every value with a for cycle, instead of using concat. Thanks for the tip.