-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
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
var piwikTracker = Piwik.getTracker(12, "http://example.com/piwik/" );
piwikTracker.trackPageView();
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:
['disableCookies', 'setTrackerUrl', 'setAPIUrl', 'setCookiePath', 'setCookieDomain', 'setDomains', 'setUserId', 'setSiteId', 'enableLinkTracking'];
Otherwise there might be side effects. Also one would have to change all calls to Piwik tracker from say _paq.push(['trackPageView])
to if (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()
or paq2 = _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.