Conversation
supportHi, since installing and using Autoptimize I’ve noticed that Post Views Counter has gone a little….awry. I’ve experimented with using Rest API instead of Javascript, but it hasn’t helped, I seem to get very strange patterns of counting. I was planning to revert back to JS method, but how can I ensure that this remains compatible with Autoptimize when using their JS optimization, aggregation and deferring? There is an option in Autoptimize to exclude certain scripts from their plugin, so my thought was just to add the relevant scripts from P.V.C. there? would that work, and if so, what JS codes should I exclude please?
Hi, In PVC, both J avaScript mode and REST API mode use the same frontend bootstrap script, so switching from JS to REST API usually won’t avoid this kind of Autoptimize issue by itself. The important part is keeping PVC’s inline config and frontend script out of AO’s JS optimization flow so their execution order stays intact. Please try adding these to Autoptimize → JS → Exclude scripts from Autoptimize: post-views-counter/js/frontend.js,pvcArgsFrontend After adding the exclusions, please: Save AO settings Clear Autoptimize cache Clear any page/server/CDN cache Retest on a single post page If you still see odd counting after that, also check whether AO has “Minify excluded JS/CSS” enabled. In some setups, excluded files can still be minified, which is worth disabling for troubleshooting.
Thanks. I am experimenting with this at the moment and will report back. I’d appreciate it if this thread could be left open for a little while I test, in case of further questions. thanks
Hi @weiser , I’m still experiencing an odd issue with the post views counter and it doesn’t seem to be related to Javscript optimization in Autoptimize after all. Wondering if you’ve got any advice i can try? I’ve disabled the JS Autoptimize settings altogether for the last week or so but I am still experiencing the same oddities with the counting as before. I still have “optimize CSS code” and “optimize HTML code” selected in case either of those could be causing an issue though? What I’m seeing is that rather than a fairly “smooth” trend over time (which is what my Google Analytics and another visits tracker shows), my graph of post views spikes up and down regularly. This is the trend showing from April in the dashboard for PVC: You can see it seems to spike between 7000/8000 one day, then drops all the way to 2000 a couple of days later. Below is how it would typically look before the changes, here’s the data below from March – note that it was late March when i installed Autoptimize and made some other changes to the caching on the site, which is when the “spiking” happened from about 24 March onwards: This is how another analytics tracker shows traffic over the last 90 days, you can see generally more consistent apart from a couple of very busy spikes, typically around 6500 per day: I am using the JavaScript counter mode in PVC still, which i always have used, and like I say, I’ve disabled Autoptimize JS options now so I don’t think it’s that causing the issue. The only other thing i changed at the time this started was shifting to a different cache plugin. I am using ‘Super Page Cache’ which is linked to Cloudflare more directly than what i was using before, and I’m wondering if that’s now causing the oddities. It almost looks like from the recent PVC stats that it is maybe counting everything, it’s just not refreshing in uniform intervals, and so one day it counts 2000, then the next maybe 9000, averaging out over time? I’m not entirely sure. Any thoughts on things I can try please? This reply was modified 1 month ago by wpsi1 .
Hi, are there any other suggestions on things I can try to help resolve this please? I’m still seeing this odd spiking pattern to the post views counter views 🙁
Hi, In PVC, both J avaScript mode and REST API mode use the same frontend bootstrap script, so switching from JS to REST API usually won’t avoid this kind of Autoptimize issue by itself. The important part is keeping PVC’s inline config and frontend script out of AO’s JS optimization flow so their execution order stays intact. Please try adding these to Autoptimize → JS → Exclude scripts from Autoptimize: post-views-counter/js/frontend.js,pvcArgsFrontend After adding the exclusions, please: Save AO settings Clear Autoptimize cache Clear any page/server/CDN cache Retest on a single post page If you still see odd counting after that, also check whether AO has “Minify excluded JS/CSS” enabled. In some setups, excluded files can still be minified, which is worth disabling for troubleshooting.
Thanks. I am experimenting with this at the moment and will report back. I’d appreciate it if this thread could be left open for a little while I test, in case of further questions. thanks
Hi @weiser , I’m still experiencing an odd issue with the post views counter and it doesn’t seem to be related to Javscript optimization in Autoptimize after all. Wondering if you’ve got any advice i can try? I’ve disabled the JS Autoptimize settings altogether for the last week or so but I am still experiencing the same oddities with the counting as before. I still have “optimize CSS code” and “optimize HTML code” selected in case either of those could be causing an issue though? What I’m seeing is that rather than a fairly “smooth” trend over time (which is what my Google Analytics and another visits tracker shows), my graph of post views spikes up and down regularly. This is the trend showing from April in the dashboard for PVC: You can see it seems to spike between 7000/8000 one day, then drops all the way to 2000 a couple of days later. Below is how it would typically look before the changes, here’s the data below from March – note that it was late March when i installed Autoptimize and made some other changes to the caching on the site, which is when the “spiking” happened from about 24 March onwards: This is how another analytics tracker shows traffic over the last 90 days, you can see generally more consistent apart from a couple of very busy spikes, typically around 6500 per day: I am using the JavaScript counter mode in PVC still, which i always have used, and like I say, I’ve disabled Autoptimize JS options now so I don’t think it’s that causing the issue. The only other thing i changed at the time this started was shifting to a different cache plugin. I am using ‘Super Page Cache’ which is linked to Cloudflare more directly than what i was using before, and I’m wondering if that’s now causing the oddities. It almost looks like from the recent PVC stats that it is maybe counting everything, it’s just not refreshing in uniform intervals, and so one day it counts 2000, then the next maybe 9000, averaging out over time? I’m not entirely sure. Any thoughts on things I can try please? This reply was modified 1 month ago by wpsi1 .
Hi, are there any other suggestions on things I can try to help resolve this please? I’m still seeing this odd spiking pattern to the post views counter views 🙁