I came here with an issue related precisely about ads and pageviews, but from a different angle and I wonder if I might have just stumbled on the actual cause for this.
Some context: I’m using Google’s Ad Manager to show a mix of our own directly sold ads with AdSense as fallback. I’m using the official Ad Plugin.
We rarely have directly sold ads in our forum, but we currently have one. Over the last days I noticed something very odd with the ads the forum: Ad Manager was reporting the banners were having clicks, but reporting to have nearly zero impressions, causing Ad Manager to report a CTR in the thousands percent because it was seeing more clicks than actual impressions.
While using Ad Manager feature to preview one of the banners directly on Discourse I noticed that these errors were being displayed on the console:
Expanding on one the errors, they seem related to the advertising.
Note that, as recommended by the Ad Plugin, we are using ‘https’ and ‘unsafe-inline’ for the CSP. I don’t know if the policy of ignoring ‘unsafe-inline’ is new, or if the hash was introduced recently by Discourse.
In any case, if I temporarily disable CSP, as expected, the errors go away and, importantly, Ad Manager started to properly report impressions.
So, it seems that in practice the ads (mostly) work, but the Google Ad Manager internal tracking to report back to thepage seems to be failing (when CSP is not disabled).
Could this issue with CSP’s ‘unsafe-line’ be the cause of the unreported ad pageviews reported on this topic?
Well okay but when i moved to GA4 on Discourse my pageviews rocketed to 3 x times what they were on UA and after moving to a different platform they’re back to 30% of what I was getting on Discourse with GA4 and much more in line with my Discourse traffic on UA. No one seems to be able to explain why, so there’s potentially something miss there.
Not sure if relevant here, but the hash is being added right after https://discourse-host/svg-sprite.
Apologies if this CSP issue is out of context here, although to me it seems related — feel free to move my posts to the Ad Plugin topic if this is off-topic here.
This is an interesting theory. I did a bit of digging to track down where the hash that cancels unsafe-inline is coming from and it looks like it is being added by the splash screen site setting. Can you try to disable that setting on your instance temporarily and see if there are any changes in the Ad Manager reports?
I can now confirm that after disabling the splash screen (and re-enabling CSP), Ad Manager is now acting normal, with impressions being reported back for the ad campaign we have been running (previously showing ~0 impressions, although dozens of clicks).
So, at least for our case, we seem to have found a culprit and a hack of it. I don’t think this affects just us though as we have a pretty standard use of the Ad Plugin with Ad Manager, and the splash screen is enabled by default. I’m not sure if the instructions of the Ad Plugin need a tweak, or if the use of hashes on CSP can be addressed. Either way, I think it needs attention as it currently breaks running Ad Manager campaigns in Discourse when using the Ad Plugin.
Happy to provide more info or test something if it’s helpful as I know it can be tricky to debug these things without already having a Ad Manager account and running an actual campaign.
Having said that, given that I posted about this on this particular topic, I should also note that the number of impressions reported by AdSense (which is our fallback for our own campaigns and takes the majority of the traffic) has not changed substantially after these workarounds (e.g. disabling CSP or the splash screen). So it seems to affect only Ad Manager with directly sold campaigns, and not necessarily if its AdSense showing an ad — perhaps AdSense uses a different way to report the impression back to Google, if it does it at all. Hence, this CSP issue may not necessarily explain the big discrepancy reported on this topic — at least I can’t see it with our particular setup, although the same CSP issue may be breaking other google code when the Ad Plugin is used.
A quick follow-up here, @mentalstring. @david has a PR in the works with a completely differect approach here, that is looking very promising:
We should be able to merge this in core shortly and test it out very soon. It promises to solve all sorts of CSP issues with ad management software (and script management tools like GTM). It might not affect AdSense impressions though, that seems to be a different issue.
Hi @mentalstring - here are some details on that new approach:
With that, you should be able to re-enable the splash screen, and all kinds of advertising / tag-management should ‘just work’ without any additional configuration. Please let us know how you get on!
This looks like a good approach, very likely to fix the issue with GAM, while perhaps even simplifying the CSP setup.
It will be a little while until I can test this myself as we are still on 3.1.5, although we plan to update soon. Will report again here once I have a confirmation.