
(Special rate for the Six Figure Blogging course until Dec 2nd.)
« How I learned typing … | Home | » Help needed: How to g…
How to only show ads after X days
03.07.05 | filed in Adsense, e, Tools
I just finished an article over at Darren's blog called "Ads: You can show them later!" which main suggestion is: Show ads only on blog posts older than some days.
I've compared the earnings of some of my blogs based on the amount of days passed, and found that I only get some cents from daily visitors. So why annoy them with advertisement when they won't click anyway? If you are wondering - I have not done the implementation on all blogs as you can see here. ;)
It will depend on your blogging software to develop the mechanism, but usually you do have a way to get to the date of the blog post. Of course, you should start slow and at first gather information whether or not you earn money on those days - it would be stupid to give that away.
How can we do that?
I use Adsense ads as example but of course this can be used by any kind of advertisement.
You can calculate how many days have passed since then and depending on the amount of days passed, you display different channel information. The following is a snippet written in PHP and the used blog software is Pivot but you should be able to adapt this.
function snippet_gad() {So if less then two days have passed, nothing is shown. If more than two days have passed, channel1 is used, otherwise channel2. Please note that this is a very simple implementation and I should just make that more than 4 days. :)
$datepost=format_date($db->entry["date"], "%year%-%month%-%day%" );
$dayspassed = (round((strtotime("now") - strtotime($datepost))/(60*60*24)-1));
if ($dayspassed>=3){
$output .="google_ad_channel =\"channel1\";\n";
if ($dayspassed>=7){
$output .="google_ad_channel =\"channel2\";\n";
}
[output other google information including the java script link ]
}
return $output;
}
But you get the idea. With this kind of separation, you could also use it to display a different type of ads if somebody comes through Google to your site than from another referrer.
To spin this even further: You could also make a distinction between the accepted language from the browser: If it is German, display a German Amazon ID, if it is English, use the US store id.
comments (2):
If I were any better at PHP, I’d like to check how this works. Unfortunately, I’m not. :-( But, it’s a great idea that I’d like to keep in mind. Thanks!
it is not really that complicated to do it in php
$datepost=format_date($db->entry[“date”], “year-month-day” );
$db->entry[“date”] is the way to receive the date of the actual post
from pivot – you just need to figure out how to use the date in your
blogsoftwares :)
The rest is the same in all cases, because once you get the date,
it is transformed in this line (should be) into the format needed
and the rest stays the same. Maybe we should collect
a list of “how to get the date in software X” ;)

