0

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?

James Coyle
  • 9,922
  • 1
  • 40
  • 48
  • Try http://stackoverflow.com/questions/14079048/adblock-plus-hids-elements-with-ids-or-class-with-the-word-ad – Mateusz Nowak Jul 26 '14 at 14:49
  • @estshy The trouble is I want the 'advert' div to be hidden but it isn't. – James Coyle Jul 26 '14 at 14:52
  • 1
    I suppose adblock simply blocks the loading of the script. You might be able to load that script via ajax and detect if there was an error. Can't test that theory right now though. – Sumurai8 Jul 26 '14 at 14:55
  • @Sumurai8 That may work. Implementation in the markup would be much cleaner too. I'll play around with it and see what happens. – James Coyle Jul 26 '14 at 14:59
  • Since AJAX is really the only way to test if an external resource loads or not with error responses its probably the only way, unless adsbygoogle.js has a variable you can check against such at `if (loaded !== true) \\ hide the div` – Wobbles Jul 26 '14 at 15:05

3 Answers3

2

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.

James Coyle
  • 9,922
  • 1
  • 40
  • 48
2

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

galeksic
  • 2,176
  • 18
  • 25
0

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;}
Robert Stevens
  • 519
  • 5
  • 9