Widget doesn't always appear?
-
I’m trying to get the stats widget to appear in my footer, showing total site pageviews for the past 7 days. It will appear in the customizer, but then not on the site. Also, sometimes it will appear on the site but only if I choose 4 days or less.
I’m on 1.0.9
-
What options are you using for the widget exactly?
If there is no data to be displayed, it won’t display the widget with a 0 value.
I’ve had the plugin running for a few weeks now, having migrated to Universal Analytics a few weeks prior, and Google Analytics itself for years, so there should be data.
I tried in both my sidebar and footer, no difference.
I changed the title, selected Pageviews and left the variable-filled text as is. With 1-4 days of data, the widget appears but if I up it to 7, it doesn’t anymore
One thing I can think of that might cause something like that would be if you were hitting Google Analytics internal “sampling mode” in the report to generate that data. But even then it should give you a good general number even when sampled.
The only way I can think of that you would end up with a sampled rate of 0 would be if all of the following was going on:
- The web property gets less than 500,000 sessions in the last 4 days.
- The web property gets more than 500,000 sessions per week (the sampling only happens when the requested report applies to >500,000 sessions).
- You are using the “Stats for current page only” option an viewing on a page that gets a tiny amount of traffic compared to the site as a whole.
Some info on sampling here: https://support.google.com/analytics/answer/1042498
The reason you would see something like that would be because the filtering (which is used to get stats for an individual page) is applied *after* the report is run. So if your date range involved 1,000,000 sessions, but then you are filtering it down to just display results for a single page that got 1 or 2 page views, those could be missed because it’s not enough traffic to be statistically significant within the sampled data. Like if the sampling drops it down to a rough guess based on 25% of the actual traffic, depending on if those sessions were part of the session, 2 sessions could be shown as 8, but most likely would show as 0 because it’s a small number within the site as a whole.
Not sure if that’s what’s going on here, but that would be my best guess based on what you are seeing.
2. My web property did NOT get >500K sessions this week
This is for a sitewide widget in Customizer.
There’s definitely something strange going on. I just tried adding it again. By default, the title is Analytics Stats. In Customizer, I was able to make the widget appear even with 7 days of pageview results but once I saved & published, it doesn’t appear on the site. And if I change the title to just ‘Stats’ or anything else, now it doesn’t even appear in Customizer. I don’t think this is caching plugin-related because W3TC is set to not cache for logged-in users.
Hmmm… it does sound like it might be caching related somehow. Any chance you could disable whatever caching system you are using (W3TC and possibly any others) just to see if that fixes it?
No matter what I try on my end, it seems to always be working no matter how I try it.
For example, I just tried the simplest setup I can think of. Going to Appearance -> Widgets -> Better Analytics: Stats, and set the options like so (see screenshot):
https://cl.ly/image/3k2x2c2A1Z0i/Image%202015-08-05%20at%202.12.37%20PM.png
Any chance you could try the same just to see if it works for you?
Yes, your screenshot is exactly what I’ve been trying.
I can try disabling caching over the weekend when traffic is much lower.
Thanks in the meantime
Just disabled W3TC and right away I can see that the widget is working. Maybe a specific W3TC setting is problematic. If I figure it out, I’ll post here again.
Nope, I was wrong. I have left W3TC off since yesterday – deactivated even – but this morning the widget is no longer appearing. I checked Admin > Widgets, and the widget is still set to appear, but it’s not. So not a caching issue.
Hmmm… not really sure how to even go about troubleshooting this one. I can’t get it to *not* work on any of the 3 WordPress blogs I have. Is there anything unique about your setup that you can think of? Like is it a site within a multi-site setup, are you using something non-standard for storing WordPress transients (temporary data)… Usually the caching system will use something different, but maybe you have something beyond the caching system as well?
My blog is the main blog of a multisite setup but aside from that… I’m running on nginx. APC is installed but only used when W3TC is activated. I’m on EC2.
Is there anything in the plugin code that would, on fail, prevent the widget from appearing? Maybe it’s a javascript conflict?
Literally the only thing that would prevent the widget from displaying would if internally it had nothing to display. *Normally* this would be because Google Analytics API is returning 0 for the query… but in your case, I think it’s something different since there are times that it shows something.
The logic for it is fairly straightforward… it checks if the query results are cached in WordPress’s transient system (used for storing temporary data in WordPress cache), if it’s not there, it queries the Google API for the data and stores it for 6 hours in WordPress’s caching.
Since your other reports work I assume (the dashboard and heat maps for example), and the widget is able to display data *initially* when created, I don’t think it would be an issue with the Google API. My best guess is somewhere, somehow the internal WordPress transient system (used to store temporary/cached data inside WordPress) is somehow getting mucked with. Like maybe the multisite install is using something custom for transients and they are getting partially removed sometimes. I say partially, because if they were completely removed, the system would just requery the Google API for the results… but it seems like it thinks the transient is there, but with a null value (like the key is there, but not the data somehow).
Dashboard and everything else work great.
Maybe it’s a conflict with another plugin, or something in the theme.
I just changed the widget to show pageviews for 1 day. Initially it wouldn’t appear but after changing to users and then back to pageviews, I was able to get it to appear.
The theme shouldn’t affect it unless the theme is loading in it’s own extensions related to the WordPress transient cache. At this point, I’d say it’s like a 98% chance something is effecting your WordPress temporary (transient) data somehow. So maybe not a conflict with something directly, but possibly indirectly because if something is changing how the WordPress transients work, that could be an issue (something changing how they are stored would be fine, but something changing how they *work* is a different story).
- The topic ‘Widget doesn't always appear?’ is closed to new replies.