New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Piwik JS Tracker: Easier way for using multiple trackers #9525
Comments
That would be an awesome improvement! Would both trackers register downloads, outlinks, etc? |
Yes I'd say so but I'm not sure if there are any problems with it. I think it should work fine though |
So this is working is it? |
PR in progress: #10085 |
Thanks.. Please keep me posted. On 21 April 2016 at 06:34, Thomas Steur notifications@github.com wrote:
Best regards, Meghashri Kirani ABOUT YOU GmbH |
@tsteur I would consider also a scenario where somebody uses two Piwik.js scripts from different versions. There is namespace conflict in such situation because all is stored in global |
* Document the new addTracker functionnality https://github.com/piwik/piwik/pull/10085/files matomo-org/matomo#10174 (comment) matomo-org/matomo#9525 matomo-org/matomo#10174 * Update tracking-javascript-guide.md * Update tracking-javascript-guide.md * Improve multiple trackers * Update tracking-javascript-guide.md * Update tracking-javascript-guide.md * Update tracking-javascript-guide.md
For example in #9518 we had a case where two scripts declare a Piwik and overwrite each other. In http://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers we explain how to use multiple trackers eg by calling
However, creating the tracker instance is not trivial and is a bit different from the standard async tracker. For example a developer would need to make sure to call methods on the tracker in this order to configure the tracker:
Otherwise there might be side effects. Also one would have to change all calls to Piwik tracker from say
_paq.push(['trackPageView])
toif (piwikTracker) piwikTracker.trackPageView();
etc. which can be a lot of effort.I wonder if there are easier ways. Eg could we maybe also provide a
_paq2
,_paq3
,_paq4
, ...?We probably don't want to pollute the namespace so maybe we could do something like
_paq2 =_paq.create()
orpaq2 = _paqCreate();
. This way one could create unlimited_paq
instances manually as needed. All a developer has to do afterwards is to replace_paq
with_paq2
and one is done. The order of the applied methods that are applied would be the same as usual etc.The text was updated successfully, but these errors were encountered: