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
2.17.1 JS-Tracking does not work anymore #10878
Comments
How do you embed your tracking code into your website? Feel free to send us a link to hello at piwik.org and leave a comment here afterwards in case it goes into spam folder. |
index.html:
After the app has loaded:
After every routing event / url change:
In the 1,5 days I had visitors which where tracked, but only around 10 percent of the usual numbers. So either the had an older version of the app loaded or the code was running for some users/browsers (but browser statistics seem to be the same). I tested it in Opera 41, there tracking did not work without
|
Maybe sometimes the piwik.js was loaded before your script was executed? The @mattab should we maybe in such a case log an error or so explaining the tracker should be initialized before Piwik is loaded? @ktrhn if you place just one _paq.push call before the loading of piwik.js it should work for you again as usual as a temporary workaround. If not, I would execute this at the end after calling all // ...paq.push()...
if (!window.Piwik.getAsyncTrackers().length) {
window.Piwik.addTracker();
} This makes sure the correct order of tracker calls will be respected |
Before using this fix, I had the same issue. I understand that it's a safety feature to keep it this way. But it could be nice to document it and add a error in log for the not standard context like mine. Thanks, |
@tsteur Thank you for the explanation. As I only load piwik.js and the javascript of the single page application (which is quite large), most of the time Piwik will get loaded first. So I will use your workaround. A note in the documentation (or when showing the tracking code for a website in the piwik app) would be nice, as I don't think single page applications are uncommon these days. |
I'm not sure how it is related to a single page application. Wouldn't it be still possible to add least define eg the following in HTML head before loading the files? _paq=[]; In theory one of them would be enough but the configuration for the Piwik tracker should be always configured upfront as explained as otherwise random bugs may occur. Maybe for Piwik 2 we could restore the old logic, for Piwik 3 we could show a warning explaining tracker needs to be initialized upfront. @mattab @sgiehl any thoughts? |
@tsteur 👍 for a smooth LTS
👍 were you thinking of a warning in the browser console (or even throwing exception in the tracker), or to show warning in the Piwik tracker code generator page, or maybe both? |
tracker code generator does not make sense. Would only confuse people etc. Instead we need to show it in the browser console if someone decides to do it differently |
Just to be clear, I was thinking of not tracking at all in that case. Or is it supposed to still "work" because it wouldn't really "work", or only in some cases when they call all methods in correct order |
would be great to track data 👍 Ideally if we can detect the necessary methods were called in the right order, and tracker could initialise properly, then tracking will work and no error displayed in this case. would it be maybe possible to display error and not init tracker only when the JS API was effectively mis-used? |
No. I will update PR to track data then. Even though IMO we should protect users from something like this. Because of such behaviour we track in couple of cases wrong data eg server side when someone tracks data for visits > 4 hours. Users do not expect this and because it still seems to "work" users assume there is no problem. Still tracking data in such cases is not helping users and over times makes certain features unusable. Eg where we ignore time > 4 hours and set it to now, it prevents users from being able to use offline feature which is needed nowadays. |
I have updated PR. FYI: It may also "break" custom tracker plugins. They might call _paq.push to an unconfigured tracker which causes tracking requests being sent to the same URL that is currently viewed instead of the tracker. IMO the Piwik Tracker should actually never work when it is not configured upfront. It will cause over time various issues created in the issue tracker, hard to reproduce issues, support requests, etc. |
as one of our key goal is to reduce support requests especially around such potentially complicated to debug issues, it is fine to not track at all and just show the error when tracker was manually initialised too early (in Piwik 3 where we can break BC and document changes). |
👍 done, changed tracker again. This will definitely reduce bug reports, wrongly tracked data, and make it easier to maintain tracker in the future and to maintain custom tracker plugins |
You're right. I changed it like that. I think the problem was/is that there are piwik extensions/addons for ember and angular which do not do it like that for some reason. But of course that is not a problem which should be discussed here. |
Interesting. Didn't think of this but does make sense. I presume in such a case you configure the tracker URL and idSite via a config and then ember / angular extension configures itself? One way to solve this would be to merge/minify piwik.js with all the other files and make sure piwik.js is loaded at the end but this adds problems when Piwik gets updated which means you would need to update the Maybe we need to rethink the tracker a bit more to allow such things in the future, eg like refs #10797 |
Just added a comment to #10797 (comment) |
Exactly. For ember I now modified the ember-cli-piwik addon to use the configuration to setup the index.html where the original piwik tracking code is used (except for |
@tsteur Just to add some insights of how we use Piwik in the company I work for. It might be an edge case but definitely something to think about. I think everything worked correctly up until it start breaking (that's how I got to that ticket). |
There would be only #10951 otherwise |
Ok so closing as #10888 is assigned to 2.17.2 |
Seems to be related to #10818
Now trackig does not work anymore in my app as the _paq property does not get initialized and just stays an array. I have to manually add
in my tracking code to activate tracking again.
The text was updated successfully, but these errors were encountered: