Browser Detection for Firefox and Google AdSense Button

Recently Google announced Referral program for Firefox and AdSense under its AdSense advertising programme.

Let us join hands with Google to spread Firefox browser and to end Internet Explorer monopoly!



[advt]

Adding a referral button to your website enables you to generate additional earnings by directing users to download or sign up for products such as AdSense.

When a user downloads and installs Firefox through your referral, Google credit your account with up to $1.

When a publisher (website) that signed up for AdSense through your referral earns their initial $100 and is eligible for payout, Google credit your account with $100.

If you do not have an AdSense account, click on the button above to sign-up.

You can see a button on the sidebar menu of this blog too. When the visitor is already using Firefox to browse your website, it is not good to advertise for Firefox again. So I added a few lines of JavaScript code to detect the current browser and display the ad button accordingly. If the browser is Firefox, it displays the Google AdSense button, otherwise displays Firefox button. Very simple.

After you sign up, replace the google_cpa_choice line with the following lines of code, and change google_cpa_choice value accordingly. That’s it!smiling

var ua = navigator.userAgent.toLowerCase();
var isFirefox = (ua.indexOf('firefox/') != -1);
if (isFirefox) {
  google_cpa_choice = "cpa-for-AdSense";
} else {
  google_cpa_choice = "cpa-for-FireFix";
}

Be the first to comment

Leave a Reply