Reputation: 10418
I would like to add a small message above adsense advertisements to signify that it is an advertisement and thank the user for not using adblock. Obviously I would like this to be hidden if the user does use adblock.
I remember doing this a few years ago by simply wrapping the advert using <div class="advert">
and putting the text inside that. It seems that adblock no longer blocks elements in this way as the ad is blocked yet the text remains.
<div class="advert">
Thank you for not using adblock!
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
Advertisements directly support the hosting of this site
</div>
I could create a script to detect adblock and hide the text with that but I would rather let the adblock script do the hiding if possible. I am mainly wondering if that is at all possible. Is there somewhere I can include the text so it will be seen as part of the advert and thus be blocked with it?
Upvotes: 0
Views: 1523
Reputation: 549
For horizontal ads, wrap your ad with a div
<div class="adHorizontal">
This CSS works for me:
div.adHorizontal ins.adsbygoogle:before {
content: 'Advertisement';
position: relative;
top: 15px;
color: #888;
font-size: .75rem;
-webkit-transform: rotate(270deg);
transform: rotate(270deg);
transform-origin: right top 0;
float:right;}
Upvotes: 0
Reputation: 2176
I'm sorry, but the correct answer to your question is non-technical and negative: you are not allowed to "add a small message above adsense advertisements to signify that it is an advertisement and thank the user for not using adblock".
"Thank you for not using adblock!" anywhere on your site or page:
very big risk, and I think it is a violation of AdSense policies.
"Thank you for not using adblock!" above AdSense unit:
"Unnatural attention" and "Misleading label" in AdSense.
"Advertisements directly support the hosting of this site":
obvious violation - "Encouraging users to click Google ads".
In order to ensure a good experience for users and advertisers, publishers participating in the AdSense program may not:
- Compensate users for viewing ads or performing searches, or promise compensation to a third party for such behavior.
- Encourage users to click the Google ads using phrases such as "click the ads", "support us", "visit these links" or other similar language.
- Direct user attention to the ads using arrows or other graphical gimmicks.
- Place misleading images alongside individual ads.
- Place ads in a floating box script.
- Format ads so that they become indistinguishable from other content on that page.
- Format site content so that it is difficult to distinguish it from ads.
- Place misleading labels above Google ad units. For instance, ads may be labelled "Sponsored Links" or "Advertisements", but not "Favourite Sites" or "Today's Top Offers".
Source: AdSense program policies
Publishers are not allowed to use language to lead users to click Google ads, such as:
- "Feel free to click an ad"
- "Contribute to the cause, visit an ad"
- "Help keep this site running, check out our sponsors"
- "We need a new server. Support us!"
Source: Ad placement policies
Upvotes: 2
Reputation: 10418
Well the solution is actually really simple. You just need to apply styles for the text to .adsbygoogle
and then use the ::before
and ::after
pseudo elements to display the text. When the advertisement is blocked the .adsbygoogle
element is not present so the pseudo elements aren't created.
.adsbygoogle {
font-size: 12px;
text-align: center;
}
.adsbygoogle:before {
content: 'Text above';
}
.adsbygoogle:after {
content: 'Text below';
}
It is simple, clean and semantic too which is always a plus. No need for extra markup or any javascript.
Upvotes: 2