Want to make money online with Google Adsense? If so, you better make sure you don’t get smart priced! One of my most successful posts covers how to avoid smart pricing by only serving Adsense to search engine visitors. That post was written for the WordPress platform. In this post, I outline how to do the same on Blogger blogs (although there are severe limitations).
Why Only Show Adsense To Search Visitors?
First, why are we doing this? The main reason for showing Adsense to search visitors only, is to try to avoid smart pricing. I won’t go over smart pricing again (go read the above post in detail), but here’s the brief summary:
Smart Pricing is a penalty Google applies to Adsense accounts that don’t convert well for the advertiser and results in you earning only about 10% of what you’d normally earn per click. Search engine visitors provide targeted traffic for the advertiser, which converts well (no problem). Regular readers and social networks visitors provide untargeted traffic, which doesn’t covert well, increasing your chances of being smart priced (problem).
After reading Grizzly’s recent post on making money online anonymously, I learnt that it’s even more complicated than that. Grizzly, who’s a master of making money online, reveals that when he writes a post his CPC (Cost Per Click) drops for a couple of days:
Whenever I post I get a surge of traffic - the surge is un-targeted (my readers) and my CPC drops for several days until readers tail off. As long as my ad impressions stay above the 3000 barrier my CPC doesn’t drop more than 10 cents a click. If my ad impressions fall below the 3000 barrier I see a 30 cent drop in earnings per click.
Grizzly also says that his CPC dropped when he received a surge of traffic from a forum. It follows that the same would happen when you receive a surge of traffic from the social networks (ie Digg, StumbleUpon, etc).
It may be that this phenomenon is separate to smart pricing, or it may be that it’s actually a part of smart pricing and that smart pricing is far more complex than anyone has guessed.
Either way, showing Adsense to search engine visitors only should ensure that Adsense units are only served to targeted traffic, which should protect your CPC and help you make more money.
Serving Adsense Only To Search Visitors on Blogger
I’ve already covered how to display Adsense units only to search visitors for WordPress and I actively use the method on this blog. However, I also have a few Blogger blogs (and Grizzley’s site is on Blogger), so I started wondering how to show Adsense only to search traffic on Blogger.
With WordPress it’s easy. You can use PHP on the server side to detect where the visitor came from, then decide whether to include the Adsense code. If they came from a search engine, the Adsense code is added to the HTML sent to the browser. If they came from somewhere else, then it’s not.
However, with Blogger, it’s not possible to detect where the user came from on the server side. The only option is to use JavaScript, on the client side, to a) detect where the user came from and b) show the Adsense code or not.
Part A - Detecting Search Engine Visitors
Detecting search engine visitors is relatively easy. We can use JavaScript’s document.referrer to work out where the user came from. Converting the code I used for the PHP in JavaScript, we can do something like:
view plaincopy to clipboardprint?
-
Note: In the document.cookie line, you must change “.scratch99.com” to your own domain!
This code detects whether the user arrived from one of a number of search engines and, if so, sets a variable called ‘sevisitor’ to true. It also creates a cookie, so these visitors can be identified if they subsequently navigate to another page (they will no longer appear to have come from a search engine).
We’ll use the variable or cookie later to decide whether we’re going to display Adsense.
So where does this code go? We only need this code once on the page, regardless of how many Adsense units we show, so we’ll put it at the top. The bad news is that it doesn’t work if you try to add it via a Blogger gadget, so we’ll have to add it to the template itself, as follows:
- In Blogger, go to Layout, then choose Edit HTML
- Make a backup of your template by clicking Download Full Template
- Click Expand Widget Templates
- Search for (near the top somewhere)
- Place the code above on the line immediately below this.
- Save the template
Your blog should now be setting the variable and the cookie.
Part B - Showing Adsense To Search Visitors
Next we need to detect whether the variable and cookie are set and, if so, show the Adsense unit. To check whether they’re set, we’re going to use the following code:
view plaincopy to clipboardprint?
- var results = document.cookie.match ( '(^|;) ?sevisitor=([^;]*)(;|$)' );
- if (sevisitor == true || results[2] == 1) {
var results = document.cookie.match ( '(^|;) ?sevisitor=([^;]*)(;|$)' ); if (sevisitor == true || results[2] == 1) {
Put this together with your Adsense code and it should look something like this:
view plaincopy to clipboardprint?
-
You’ll have to replace the xxxx’s with the appropriate numbers from your Adsense code and you’ll have to change any other details (such as ad width and height if you’re not using a large rectangle).
There’s no need to replace special characters with HTML entities, as mentioned in my post on showing Adsense within the post body. In fact, that won’t work in this case.
What this script does is first check whether the variable or the cookie is set and if so, builds a string containing the Adsense code, then writes it. We have to build a string then write it, because there’s an external script called by the Adsense code. If there wasn’t an external script called, we could just strip the