Skip to content
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

Multiple inclusions of Matomo across different versions breaks functionality #13007

Open
OscarEriksen opened this issue May 29, 2018 · 8 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@OscarEriksen
Copy link

OscarEriksen commented May 29, 2018

We have seen issues where a client already is including Matomo (or older Piwik-versions) from a third party provider, and then they include our instance of Piwik/Matomo. Regular script-tag inclusion with your tags.

This non-encapsulation creates issues where they (kind of) override each other and results in crashes, especially if several different versions of Piwik/Matomo from different providers, is included where versions may differ.

How would we go about solving this issue; and encapsulating (namespacing?) one instance to not be able to get modified by other inclusions of the same software?

@sgiehl
Copy link
Member

sgiehl commented May 29, 2018

You want to track the same site into multiple matomo instances? Guess this post should help: https://matomo.org/blog/2017/02/complete-guide-tracking-websites-web-apps-multiple-piwiks-easily-efficiently/

@Findus23
Copy link
Member

I agree, you can find more about this idea here: https://forum.matomo.org/t/rename-paq-possible/27460

@OscarEriksen
Copy link
Author

Thanks for sending those URLs, we've checked them earlier but together they may solve our requirements. We have checked it out previously but the issue in its core is that we have clients who from one agency include Piwik, and then they include our (other version) of Piwik; and then bad things happen. Especially if the previous included Piwik major version differs.

@tsteur
Copy link
Member

tsteur commented May 29, 2018

What exactly isn't working? I don't recall too many changes in the tracker or tracker API since the last major version.

The only problem I can see is that the piwikAsyncInit and piwikPluginAsyncInit will be executed twice in this case which it actually very likely shouldn't. This is something that could be likely easily fixed but needs to be verified.

Otherwise depends how you embed the various trackers and how everything is defined. Likely the problem is really due to multiple _paq overriding each other or so. In this case features like addTracker etc would need to be used I suppose (if possible).

@OscarEriksen
Copy link
Author

Really appreciate how helpful you are with this issue. And any further pointers in the right direction would be great. But we thought initially that it would be possible to just rename _paq-variable, or in any other way not reveal "our" version of the script to the outside world by variable scoping.

If we could easily rename piwik.js, and window.piwik (or the equivalent) and the _paq-variable it would be a godsend, but wouldn't really fix the issue for real.

The actual error is this:
TypeError: The method 'setAccountId' was not found in "_paq" variable. Please have a look at the Piwik tracker documentation: http://developer.piwik.org/api-reference/tracking-javascript ourTag.js:12:8933

And is caused when a client (such as a company) includes piwik/matomo (often different versions, maybe version 2 or version 3, etctera) from different agencies that help them with tracking.

@tsteur
Copy link
Member

tsteur commented Jun 8, 2018

setAccountId is not a method we have in our tracking code so that can't really work. Seems like they customize the tracking code which is not quite supported.

@feyssericAzalead
Copy link

Hi,
We faced a similar problem.
We have a tag tracker used by our clients which is using Piwik 2, and we use the Piwik.addTracker method.
The site is using another tag based on Piwik 1 I think, not sure about the version but at least it is not providing Piwik.addTracker interface.
Their tag is loaded first so we are using their implementation of the global variable Piwik (because Piwik client JS is checking variable existence before loading it) and it fails with window.Piwik.addTracker is not a function error.

It would be great if we could easily rename, or even better, use a local variable scoped inside our tag, not shared with other third party tags.

@tsteur
Copy link
Member

tsteur commented Jun 11, 2018

I don't think renaming _paq would help much when using two different Piwik/Matomo versions when some methods aren't available. That's because once window.Piwik is loaded, the 2nd file won't assign window.Piwik again. A solution may be probably to limit the scope of window.Piwik using modules or so.

I doubt we will be working on this here soon. I would highly! recommend to get the people to update their Piwik 1 and Piwik 2 to the latest Matomo for security purposes etc which fixes the problem as well but I understand you can't get other companies to do that...

@Findus23 Findus23 added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

6 participants