Ubuntu / Linux news and application reviews.

Rotating Ads Using A Simple JavaScript Function

I used an 468 x 60 Adsense banner ad under post titles and wanted to experiment with a large rectangle (336 x 280) to see which one performs better. But page impressions / clicks are not constant so how do you know if one ad or another is actually performing better? Well, you can display each ad on 50% of the pages, randomly and automatically, by using a simple JavaScript trick. The same JavaScript code can also display different ads so you can rotate ads from multiple services. Here is how:

You Can Now Change the Google Adsense Font Size

adsense font sizeGoogle Adsense blog reports that now you can change the font size for Adsense.

You can select from small, medium, and large font sizes for ad units on pages in Latin-character languages. Just like with the current font face options, size options appear in every account but will only be applied to ad units on pages primarily in Latin-based characters for now.

The font size you choose will be applied to the body of the ad, with the title scaled appropriately. In order to fit the ad text correctly, the actual font size will vary for each format size, font face, and user-specific settings such as browsers and operating systems. In addition, some formats sizes currently have very limited room, so the font size application will be most apparent in cases where the number of ads appearing in your ad units varies automatically in order to maximize your performance.

Your ads are currently set at the default size for AdSense, which is the equivalent of 'small'. You can select a new font size on an account-wide basis in the Ad Display Preference section of your My Account tab, or on an individual ad unit basis for new and existing ad units.

Implement AdSense Depening on Post Author for a Wordpress / Blogger (blogspot.com) Blog

Let’s assume that you are the administrator of a team blog that has multiple guest authors.

The revenue sharing arrangement is such that all writers get to keep a fixed percentage of the actual AdSense revenue generated from articles that they have written.

This arrangement, from the perspective of team members, maybe better than dividing AdSense revenue based on pageviews because the author is getting exactly what he earned. You can have less number of pageviews but if the CPM of your niche is high, it kind of balances out.

Now to put such a thing in place, you have two options – either ask all the authors to open separate AdSense accounts and send you their ad tags or better still, you can have just use one AdSense account (your own) and create separate channels for all authors. Let’s see how:

Say your blog (hosted on WordPress or Blogger) has three authors – Sam, Peter and Matt. Go to your AdSense dashboard and create three separate custom channels – give each channel a name that matches with the name of author.

Now create three different ad units (of the same format) but assign a different channel to each of them. You can follow a naming convention like Leaderboard_Peter, Leaderboard_Sam, etc.

Get the AdSense code corresponding to the AdSense channel you just created and it will look something like this.

<script type="text/javascript"><!--
google_ad_client = "pub-xyz"; /* Leaderboard - Peter */
google_ad_slot = "123789";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

The code will be exactly similar for all other ad units (per author) with one exception – the value of google_ad_slot will vary depending on the author and this is something that will help us determine the exact AdSense earnings of different authors.

To get the author name of a post on WordPress or Blogger, you can use the following code:

  • Old Classic Blogger: <$BlogItemAuthorNickname$>
  • New Blogger:
  • WordPress Blogs: – you may even consider suing get_the_author_login();

Now all you need to do is write a simple piece of JavaScript code that maps the author name and google_ad_slot values correctly. This is the code for WordPress:

<?php function get_ad_codes($author) {
if($author == 'peter')
return '123789';
elseif ($author=='sam')
return '987878';
else // default, no author found
return '964743';
} ?>


Now the AdSense code in your WordPress blog template will be something like this:
<script type="text/javascript"><!--
google_ad_client = "pub-xyz";
google_ad_slot = "<?php echo get_ad_codes(get_the_author());?>";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

To implement it in Blogger, go to Layout > Edit HTML, check "Expand Widget Templates" and search for:
data:post.body
and enter the code like in this image:



Let’s understand the above coding. We are going to use b:if tag, which is the conditional tag and using this we can use simple if-else logic in our template. The first line b:if cond=”data:blog.pageType == “item” checks for the post page ( the individual page of the post ) .
Second line b:if cond=”data:post.author== “David” checks if the Author is “David“. Here David is the display name of the first author. If the condition is “true” , viz; author is David the code inside the b:if and /b:if tags will be displayed. Hence, the Adsense ads will be displayed from David’s Account . Similarly the code flow will go for the another author Techpyala here ! You can add as many as authors as you like!

When the payment cycles is near, group the AdSense report by channels and there you’ve the exact earning data per author.

[sources: labnol & arpitnext]

Google Links Google Analytics to Adsense

The integration between Google Analytics and Google AdSense is a significant upgrade for AdSense's limited reports. Until now, AdSense didn't offer reports for individual pages and users had to manually create custom channels to track the performance for up to 200 pages.

The AdSense section from Google Analytics includes a lot of new information: the list of pages that bring the most important revenue, the most profitable referrers and you can find even more by creating custom segments.



Google Analytics blog has more details about the integration and the way you can link your AdSense account with Google Analytics.

Google AdSense Video Units Discontinued

google adsense video unitsAdSense video units, a program that allowed AdSense publishers to embed YouTube videos along with Google Text ads, will be discontinued from April 2009.

google-video-ads

Unlike referrals, the video units weren’t really popular among website owners so in case you haven’t seen an AdSense video unit before, here’s a screenshot for you.

retiring-ads

AdSense video units were first introduced in October 2007 for English websites but according to a notification displayed inside the AdSense dashboard, the program will be retiring next month.

3 Ways to Get Click Statistics for a Link

What you could use click statistics for:

  • you can see how many clicks an ad gets
  • see how many click a link of your gets on Twitter (just an example) (see Method 2)
  • if you have an ad in two places (image or link, but most probably link because who would want to put the same image ad twice?), you can see how many clicks each of them gets, so you can compare and re-think where to have your ads placed
  • you have links to some of your posts in a few places and want to know which one drives the most traffic to that article
  • the third method is for Google Adsense, integrated in Google Analytics and helps you see more about the people who click, like where they come from (referrer, search engine and so on)

Method 1: the only website that shortens urls and allows you to see the click statistics:

http://cli.gs is the only website that i know of, which shortens URL's for which you can view click stats. You need an account (free) for this. Can be used with UrlbarExt Firefox addon for generating link automatically. To use the stats, you need to edit it's syntax in the UrlbarExt Preferences: Tiny tab. Make cli.gs default, in the api field enter:

http://cli.gs/api/v1/cligs/create

and in the arguments field:

url=%?url%&key=<your_api_key>&appid=77

and replace <your_api_key> with you api key which you can get from http://cli.gs, after you have an account and login.

Method 2, for clicking any link / ad (except adsense):

You need an account (free) on histats.com and install the initial code on your website (either visible or invisible, but make sure it's the one using java-script), then go to Special > Manage Special Pages / Click and under "Manage CLICK COUNT", add a title for that link and it's url:

photobucket

Then click “Insert”, and you will receive a new link, which you'll have to place instead of the original one. And… voila :)

Method 3, Google Adsense click stats (analytics), which it is said to be the only way to also track click in Firefox, not just Internet Explorer:

You will of course need a Google Analytics account, where you have to create a new “Goal”:

-in the URL field, enter: /asclick

-in the NAME field, enter: AdClick

-make sure "case-sensitive" is not checked!

Then you save this file on your computer: astrack.js and upload it to a host, either on you host, googlepages.com or whatever, then enter the below code in you website source, after Google Analytics' tracking code (above should be just fine):

<script src="http://path_to_astrack/astrack.js" type="text/javascript"></script>