How to use two incompatible version of Piwik on a website (or how to avoid overlapping global variables)


Here is my issue, I am using Piwik 2 and it is declaring a global variable window.Piwik. But another third party tag is also installed on the same page and presumably using a prior version of Piwik which is overriding the global variable window.Piwik with less features than Piwik 2. The result is that Piwik 2 features are not accessible.

How could I solve it without destroying the Piwik global variable already existing ?
I would like to load Piwik in a custom variable, the best would be not global :slight_smile: but I also don’t want to change piwik.js file.

What are your thoughts on it ? Did you face it already ?



You can find some information about tracking a page to multiple piwik server here:

But I can’t guarantee that this will work with different versions.

The best solution is of course upgrading to Piwik 3 on both server.

I cannot upgrade a third party tag :smiley:
This documentation does not apply to my case because it assume both tag are on same version.
My issue is that a Piwik version 2 will not load if a Piwik version 1 is already on the page :confused:

It would be cool to be able to encapsulate a Piwik version into a controlled scope.