How To Hide Adsense From Social Traffic
Read on to find out How To Hide Adsense From Social Traffic from Stumbledupon, Digg, Technorati, Etc. The secret is to add a little JavaScript around your Ads, so that they will only be displayed if the visitor comes from a search engine. To see this in action, visit this site via search engine and an Adsense ad will replace the banner on top of this post
- Why Hide your Ads?

There is plenty of authority for hiding your ads from social traffic so you can increase your adsense CTR (from Grizzly’s Make Money Online Blog) and not have a lot of “views” that won’t ever get clicked. Here’s a direct quote from Vic Franqui; “One last thing – if you get a lot of social media traffic don’t run adsense. Only use adsense if you draw targeted search engine traffic”.
So now you can run Adsense even if you get masses of Social traffic – If you run a WordPress blog you can use the ozh who sees ads plugin, but there is no easy plugin for Blogger or your normal website, so I have made up some JavaScript to use anywhere you want to show your ad to search traffic.
- Wrap the ad in an “iframe”
Some ads like Amazon have the code already wrapped in an iframe, so all you need do is wrap this (green) Script, around your ad code (red). The script detects if the referrer is Google, Yahoo, etc and displays the ad.
<script type="text/javascript">
<!––
var myArray = [];
myArray[0]= '/search?';
myArray[1]= '.yahoo.';
myArray[2]= 'search.';
myArray[3]= '/search/';
myArray[4]= 'images.google.';
for(var i=0;
i<5;
i++) {
if (document.referrer.indexOf(myArray[i]) > -1)
{
//––>
document.write('<iframe src="http://rcm.amazon.com/e/cm?t=youraccount-20&o=1&p=26&l=ur1&category=computers_accesories&banner=1SKRXV416ZYVKCEGXQR2&f=ifr" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>');
}}
</script>
Substitute your ad code for the code in red above. This will work with any code that is completely wrapped in an iframe.
This can be a problem because Blogger, for instance, will overide some scripts you include. The answer is to source the Adsense code from an outside file. Pop your Adsense ad in a plain html file (adsense.htm); upload it to some place you can access; and call it as the source (src) of an iframe -
<script type="text/javascript">
<!––
var myArray = [];
myArray[0]= '/search?';
myArray[1]= '.yahoo.';
myArray[2]= 'search.';
myArray[3]= '/search/';
myArray[4]= 'images.google.';
for(var i=0;
i<5;
i++) {
if (document.referrer.indexOf(myArray[i]) > -1)
{
//––>
document.write('<iframe scrolling="no" style="width:125px;height:125px;" frameborder="0" src="http://YourSite.com/adsense.htm" marginheight="0" marginwidth="0"></iframe>');
}}
</script>
Edit the above URL (dark red text) to point to where you uploaded your adsense.htm file, and adjust the width, height to match your Adsense ad
There you go – paste one of the above sets of script into your web page wherever you want the ad to appear. With Blogger, use an HTML/JavaScript Gadget, or else paste it directly into the HTML template in your header if you prefer.
- Try it and See for Yourself…..
Click on Site Synergy with Keyword Coherence for my Key Word Coherence site and you will see no ads, but Google (or Yahoo) for keywordcoherence and click on the SERP link to that same site and you will see that a banner ad in the header from Amazon and a Google ad in the side bar have appeared, because the referrer was a search engine.
Be sure to edit the iframe dimensions to match your ad and check that your edit program paste function didn’t put left and right quotes into the script instead of plain quotes. Get that right and you will have learned how to hide Adsense from social traffic!
Update – PHP Alternative
- If you prefer to code this trick using PHP then do this:
Insert this code where you want the ad to appear
<?php include ('incl_adsense.php'); ?>
- where incl_adsense is this file:
<?php
function searchengine(){
$ref = $_SERVER['HTTP_REFERER'];
$SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
foreach ($SE as $source) {
if (strpos($ref,$source)!==false) return true;
}
return false;
}
if (function_exists('searchengine')) {
if (searchengine()) {
echo "<script type=\"text/javascript\"><!--
google_ad_client = \"pub-yourcodexxxxxxx\";
/* Banner468x60 11/05 */
google_ad_slot = \"xxxxxxx0212\";
google_ad_width = 468;
google_ad_height = 60;
//--&rt;
</script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>";
} }
?>
I find that all these ‘plugins’ tend to slow WordPress down too much at loading, so there is a good case for using this PHP alternative rather than a plugin to hide Adsense from social traffic
- Please notice that where the Google ad script is included in PHP you need to ‘Escape’ all the double quotes – like this: script=”ad text” must be edited to read script=\”ad text\” and change any ’slanted’ quotes like ‘ and “ to vertical quotes like these ” ‘
Update on the Update
This post is getting way too complicated. I have been asked to upgrade these codes to display an alternative ad to social traffic, so I have made a new post over on my Teaching Blog
The 109 Day Link Building Explosion Review
April 6th, 2009The 109 Day Link Building Explosion Review.
The Tucson SEO Solutions website offering the The 109 Day Link Building Explosion leaves me with serious doubts as to the SEO competence of its author. The scheme is all about mutual linking and offers a 109 day series of 4 – 5 links with reviews. The concept is “that you would leave a comment and join in on what we like to call ‘Scratch My Back Marketing’. We would then scratch your back with a Do Follow Keyword Luv anchor text link to the web page of your choosing“. Great idea! Excellent theory, I thought, but the reality is:
It seems to me that the Author [Signs herself only as Admin] has missed the most important point of the project: If you want to encourage users to join in with commenting, and linking as a mutual help exercise, then it seems fundamental to me that you need to make the reviews attractive to your readers so they will WANT to visit the site. If the only things you can find to say are negative, then surely it makes sense to find other sites that you CAN be positive about?? It’s quite illogical to publish negative reviews of sites that you want people to visit.
Here is the Tucson SEO review of the site owned by the creator of CommentLuv. ”
Fiddy P - http://www.fiddyp.co.uk
This blog covers a wide variety of topics from WordPress to marketing a website. Today there was a discussion about adding video’s to a site. This blog also uses the plugin Comment Luv. Comment Luv pulls your latest blog post into your comment and provides a link to that post. So what you end up with if you have a blog is two links for one comment. We are upgrading our site and we will be adding this feature.
Given the enormous contribution this plugin makes to blog back-linking – it amazes me that Andy Bailey is given no credit here, in fact it seems the author is quite unaware that he is indeed the plugin’s owner.
Here’s a quote from Day 85. It seems that Tucson SEO expects us to be thankful for her ‘taking the time to visit and write a short review‘.
“This blogs link and review were pulled and here’s the reason why. I took the time to visit their blog and write a short review. This was their reply on this blog “thanks for the link.” Now, considering that the blog is about being grateful, this certainly shows a lack of gratitude. I am flabbergasted. It would lead one to believe that the gratitude suggested on their blog is a marketing ploy rather than a serious attempt to express gratitude… Wow!”
With a little bit of luck, the ‘Review’ of my blog will also be ‘pulled’ after this response.
Here is her ‘Review” of this blog:
One thing that you can tell is that the blog writer has a much reddened face and a healthy crop of grey/white facial hairs. The tagline reads “monetize your site.” This explains what the blog is about every well. It also uses the Comment Luv plugin! So I ask again why do you not have a blog?
Well I’m sorry Geraldine that my high blood pressure and ancient whiskers aren’t to your taste. I’m taking regular pills for the first, and praying about the ever-increasing daily onset of the second fault, so maybe you could overlook it this time??
Seems that The 109 Day Link Building Explosion has now collapsed, according to this post : the PC with the files and passwords died[Sic].
Tags: 109 Day Link Building Explosion, CommentLuv, Review
Posted in Rants | 36 Comments »