Exclude topic from AdSense


on our forum we allow artistic nudity to be posted. However, this is against the AdSense policy and from time to time they require us to remove AdSense from specific pages.

I suspect this can be achieved with some custom Javascript that compares the current topic ID against a blacklist and then disabled AdSense for that topic, but I haven’t been able to figure this out.

Has anyone tried something similar? I’d really appreciate some help with this.


Why not archive those topics? Archived topics are excluded from google indexing. This would prevent new replies, though.

You could also make them unlisted topics which would achieve the same effect without preventing replies.

These topics are allowed under our content policy, so I have no reason to hide them from users.

If you serve AdSense ads through Google Ad Manager (formerly DFP), perhaps you could do something like this:


1 Like

Maybe you could limit such “specific pages” to a category requiring being in the TL0 group?
Search engines do not register accounts and belong only to the everyone group.


I’m using plain old AdSense, so I’m afraid that won’t work.

Hmmm, but that would take the topics out of the context of their current category. I don’t think that’s a good idea either.

So far, I’ve tried writing some CSS rules that use the [data-topic-id="12345"] selector to target the adsense blocks on that page and set them to display:none, but that selector doesn’t get used until the posts stream. Since I also have an ad at the very top of the page, I can’t target it.

So perhaps I can write some Javascript to just compare the current topic ID to a defined list and use jQuery to insert some styling ad needed.

The question is now: how can I access the topic ID from Javascript, in a way that doesn’t require any additional server requests?

Google Ad manager can fill in your unsold inventory with AdSense ads, so if AdSense itself doesn’t have a feature you need, switching to Google Ad Manager to serve those same ads could give you more options.


1 Like

I’m revisiting this topic because AdSense just paused ad serving on our entire site because of a few infringing posts. Best would be if I could not render ad units on selected pages at all. Is there any way I can prevent the Ads Plugin to run on selected pages, or would the maintainers be willing to add a setting to not render ads on selected topic Ids?

For the time being I’ve moved the affected topics (only 6, some of which were very old) into a category that nobody can access.



I would say a tag is the way to go, I support a no_ads_tags site setting


I thought about that too, but the issue with tags is that users can remove them again (you can’t ‘lock’ a staff tag, right?). I need to be absolutely sure no ads will be shown on those topics, so I need iron control over the exclusion list - a ‘don’t remove’ policy won’t be enough.

1 Like

Tags support all sorts of magic. They can be hidden staff only, for example ;p


Either way you’re going to need a better solution than display:none, if Google catches that they can terminate the account outright.


:mindblown: I never realised that, that’s fantastic!

Yes, I quickly realised that and made the topics completely inaccessible to anyone (except myself) instead while I’m looking for a better solution.


Hidden tags, and hidden staff only tags are super handy for all sorts of use cases.

On meta we use “staff only, visible” for a “planned” tag (which only we can apply)

“staff only, hidden” are handy for cases where you want to group some topics but don’t want the community to know about it. For example: controversial-topic tag or no-ads tag.


I also support a “no_ads_tags” setting. Will add it to my list.


I added the new setting to the ad plugin today. Consistent with the others, it’s called “no ads for tags”. This won’t prevent Google from crawling those pages, so it won’t avoid getting banned for content violations, but I hope it helps in other situations. This can help you get re-approved for AdSense after being banned for content that violates their terms!

We’ve got a few ways to disable rendering ads now. Enjoy!


Thanks Neil! I just did some testing and it works great, except for one thing: if the tag is set to ‘visible only to staff’, ads are still served for regular users. I have set them to ‘visible to everyone, but only staff can use them’ for now, but this is not ideal.


(I may be missing something, but) it would seem like a visible NSFW tag would be a good thing. (you likely have other tags you need to hide)


We do have that, but we’re struggling to re-enable adsense on our site and are agressively tagging topics that contain certain keywords to not have ads. These may in fact not be nsfw, like people discussing nudity but not actually posting any images. To not annoy these users I’d like our more neutral ‘no-ads’ tag to be invisible.

1 Like

So it’s just a set of keywords that Google cares about?

So you just need a plugin that assigns the tag to posts containing any of those words.

Maybe what you need is a plugin that masks this keywords except for people in a version group. Then everything could get an ad and people would be encouraged to subscribe (or self select into the group if you’re not selling subscriptions) in order to see those words.

And I guess that the… Uh… Thing that blocks words isn’t enough.