Make Tracker work when initialized after piwik was loaded or when using multiple trackers without _paq #10951
Labels
Enhancement
For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Milestone
In #10878 (comment) we also discuss about how to be using Piwik JavaScript Tracker when piwik.js is loaded first and only initialized later. Eg we could initialize Piwik like this:
Ideally, it would have always looked like this as this is clear. We actually define to add a tracker and configure it. If no
addTracker
is called, no tracker gets added and no methods executed. This would have so many advantages and I cannot think of any downside. If idSite and trackerUrl is not configured, we would pretty much ignore these requests because we know there is no tracker configured instead of current behaviour where we would send the requests to the current website URL which doesn't work.When receiving an array of configurations we would be able to sort the methods before executing them and it wouldn't matter whether Piwik is already loaded or not. I think this version is even more readable etc and best: I think we could implement it in a way to keep BC although not 100% sure as it is a bit tricky to not ending up with 2 trackers in this case.
Any thoughts on this?
Current implementation is super buggy and does eg not when calling _paq after Piwik was loaded eg addTracker wouldn't work correctly, custom tracker plugins wouldn't work correctly, cookies wouldn't work correctly and more
The text was updated successfully, but these errors were encountered: