This is PR for Piwik 3 for https://github.com/piwik/piwik/pull/10888
To test use eg
Then initialize tracker after document was loaded via
_paq.push. You will see a console message and no created tracker. When using _paq.push for tracking, the Tracker needs to be configured upfront. Otherwise bugs may occur.
Updated PR to still track but also log a message
Updated PR again to not track when tracker is not initialized upfront
setSiteIdeven after the tracker was initialised, the tracker should initialise without error. Ie. the following code should not trigger an error but currently it does:
If we don't init tracker when setSiteId/setTrackerUrl were called in the right order (even after tracker init), then we should track the data for sure, or alternatively not merge PR for now
Piwik Analytics error: _paq.push() was used before the Piwik tracker was correctly initialized. To initialise the tracker please make sure to first call the two methods 'setTrackerUrl' and 'setSiteId' via _paq.push(). Alternatively, if you do not use _paq.push you may intialise the Piwik tracker via: 'Piwik.getTracker( trackerUrl, siteId )' and call methods on the object returned by getTracker.
but it may fully work as tracker methods may not be executed in the correct order.for the
Piwik.addTracker()method -> do you maybe have an example?
There are plenty of reasons why it won't fully work just search for issues in the issue tracker that are related to order. Eg we create cookies even though we shouldn't , or create cookies wrong domain etc.
I can't do anything else here. Happy to close PR and it just won't keep working for users. Here was suggestion on top for https://github.com/piwik/piwik/issues/10797#issuecomment-263140282 but I likely won't find any time to work on it
Also see comments where we discussed it. Eg custom tracker plugins won't be working with it etc