I am developing jquery plugin, I want to incorporate Google Analytics inside it and want to track events on my plugin.
Confusion is will it report to both, my Google Analytics Stats and Website(website which integrated my plugin) ?
3 Things to be aware of when doing this:
Be sure to tell your users or give them a way to opt-out if you are distributing this plugin. I can't say I've seen many jQuery plugins that have tracking included (for obvious reasons).
Use a different GA property than what you're using for your website.
Use tracker namespacing.
For analytics.js
:
ga('create', 'UA-123456-7', 'auto', {'name': 'myPluginName'});
ga('myPluginName.send', 'pageview');
Or for ga.js
:
_gaq.push(['myPluginName._setAccount', 'UA-123456-7']);
_gaq.push(['myPluginName._trackPageview']);
For more details visit Google Analytics site: https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApi_gaq
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With