By: Mike Axiak
“There’s so much to do with our ads!”
On my quest to show you— the Chitika publisher —cool tricks with JavaScript, I’ve had to search for things that would be really useful to you. My hope is that you may have not have even thought of the things that you can do with our ads, and more importantly do not violate our Terms of Service. The following gem is one such JavaScript trick that could be useful to every blogger out there who’s thinking about monetizing their traffic.
Thus, part two in this series is: Using JavaScript to show ads to selected users.
Using the correct JavaScript code, you can select which of your users see Chitika Ads. How? Suppose you run a blog or forum, and you want to monetize your traffic (don’t we all). However, you have a group of loyal readers you do not want to upset. Truth is, you don’t have to; most revenue for our ads will come from people searching for what they want!
In this example, I will show you an RPU that only shows itself for traffic from Google, and for no other traffic.
Here’s the example code:
<script type="text/javascript"> <!-- ch_client = "demo"; ch_type = "rpu"; /* The rest of your code here... */ if (document.referrer.toLowerCase().indexOf("google.com") != -1) { document.write("<" + "script type=\"text/javascript\"" + " src=\"http://scripts.chitika.net/eminimalls/mm.js\"><" + "/script>"); } //--> </script>
By using the document.referrer JavaScript variable, we can ask all sorts of questions regarding where the user just came from. Using document.write, we can selectively activate or omit Chitika Ads. As you can see, the combination of the two becomes very powerful!
Do you have any ideas or questions of how to selectively show our ads based on anything besides Google traffic? Please share in the comments!