jehna / ga-lite

Small, cacheable and open version of Google Analytics JS client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple tracking codes?

janiosarmento opened this issue · comments

Please, how do I enable multiple tracking codes with GA-Lite?

Thanks!

I can't understand why you'd want to... I suppose you could use script twice but sites are unique.

I need my site to be tracked twice.

With ordinary Analytics code I can do:

<script type="text/javascript">(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create','UA-xxxxxx-1','auto');ga('send','pageview');ga('create','UA-xxxxxx-2','auto','fdola');ga('fdola.send','pageview');</script>

I saw a closed issue stating this has been enabled in GA-Lite, but I can't find how to properly do it anywhere.

Multiple tracking codes are fully supported by ga-lite, and it's common to use them.

You can use multiple tracking codes just like you would do in normal analytics.js, just follow the README's instructions about migrating from analytics.js.

More specifically:

Replace any ga() function call with galite()

So in your case this code:

ga('create','UA-xxxxxx-1','auto');
ga('send','pageview');
ga('create','UA-xxxxxx-2','auto','fdola');
ga('fdola.send','pageview');

translates to ga-lite by replacing all ga() calls with galite() calls:

galite('create','UA-xxxxxx-1','auto');
galite('send','pageview');
galite('create','UA-xxxxxx-2','auto','fdola');
galite('fdola.send','pageview');

Closing this issue, let me know if you encounter any bugs using multiple tracking codes.