ads-txt icon indicating copy to clipboard operation
ads-txt copied to clipboard

Assets are getting caught by ad blockers

Open helen opened this issue 7 years ago • 3 comments

This is especially noticeable with the JS and CSS files, but also happens to the plugin icon from the .org repo. I'm not sure what can be done about this in the plugin itself vs. having to ask various ad blocker lists to whitelist. One would think somebody managing an ads.txt file wouldn't want to be blocking ads on their own site but who knows, and it's a silent non-blocking error so it just makes the plugin look less awesome than it actually is. Any ideas/experience with this?

helen avatar Mar 02 '18 05:03 helen

We have this issue in Site Kit as well, when WordPress admins have an Ad blocker enabled and try to set up AdSense it usually fails because our REST API endpoint is blocked.

To help here, we added ad blocker detection, then warn users to disable before they try to set up AdSense (or later if they are viewing AdSense data). Code: https://github.com/google/site-kit-wp/search?q=isAdBlockerActive&type=code

adamsilverstein avatar Nov 23 '20 21:11 adamsilverstein

Thanks @adamsilverstein! I didn't quite trace it all the way, but am I reading right that it's related to canAdsRun?

An approach I had started thinking about was basically the way core does .no-js, having a message/notice in HTML that an ad blocker appears to be running that then gets hidden by the JS if it does manage to load. For this plugin that's probably a reasonably accurate lightweight route to take, just have to work on the messaging and what to tell users to do about it.

helen avatar Nov 23 '20 22:11 helen

The approach you describe matching the way core works sounds good. It would be nice if implemented so that the notice was hidden until the page loaded, unhide if ads are blocked.

am I reading right that it's related to canAdsRun?

Yes exactly, the Site Kit code (which is admittedly obtuse) relies on an underlying mechanism where we load a file included in the plugin named "pagead2.js" which has a bit of code that sets a global canAdsRun. Ad blockers block that file from loading when active. Everything else relies on that global, and since our UI is mostly JS based we can respond accordingly.

adamsilverstein avatar Nov 25 '20 20:11 adamsilverstein