By: Mike Axiak

“JavaScript is fun!”

Recently I’ve been working through a lot of our JavaScript, so I am inspired to write a little about how to make the most out of our ads using this language. This is the first in a series. Please note, however, that these posts are not for the faint of heart!

In an earlier post, Karla mentioned that the order in the JavaScript code before the <script> tag does not affect our ads. This is true, but you can do a lot more than just adjust the order of this code! You can write pretty much any JavaScript you want. As long as you specify the parameters you want before the <script> tag, you’re ad will display the way you intended.

This is great, but what does this mean to me?

JavaScript has the wonderful ability to quickly determine what kind of person is visiting your site. To illustrate, I will give an example each post in this 3-part series.

Without further ado: Part I: Categories based on user’s system

Suppose, for instance, you run a laptop review site. You happen to know that, no matter what page the user is visiting, if they are running an Apple product (MacBook, iPhone, …), they will more likely click on an ad for an Apple laptop. If, however, the user is running anything else, they will more likely click on an ad for a PC laptop. To do this, one simply uses the navigator.appVersion window variable.

Here’s the example code:

<script type="text/javascript">
<!--
    ch_client = "demo";
    ch_send_title = 1;
    if (navigator.appVersion.indexOf("Mac") != -1) {
      ch_default_category = 460;
    } else {
      ch_default_category = 9007;
    }
//-->
</script>
<script type="text/javascript"
     src="http://scripts.chitika.net/eminimalls/mm.js">
</script>

You can see from the example that we were able to (very easily) check to see if the person is using a Mac operating system or not. Now, this is an example. I do not actually know if this will improve CTR, but I think it is certainly worth a test.

This is the first of three I am going to give. If you have any examples, please share in the comments!

Posted By: Mike Axiak, Web Developer A.K.A The Hacker King