I need to geotarget AdSense ads. However, the page is static html. It won't even do virtual includes. So I was wondering, knowing slim to none about javascript, whether it would be possible with some javascript. Perhaps by including some img from a dynamic page which on it's turn finds out the visitor's location and alters the img accordingly. Then according to which img is returned, the javascript outputs the ads or not. Is this possible? Our visitor tracking works like this with a javascript img pulled from the tracking server. By just that they know nearly everything about the visitor so I was hoping to port that back to my site and show relevant ads if the visitor is from the USA. (We only ship UK but rank well world wide so want to monetize on the traffic.) I have an IP database already and this idea works just fine on my PHP pages. So... Is this possible? ( if yes, then I'll ask how later... ) Gracias in advance.
First you are going to need a geotargetting database to determine the location based on IP. The easiest way (for me anyway) would be to have a PHP script serve up your images. Having that PHP script query your database to determine the country first.
I have the database and have such a script working successfully on a .php page. The basic idea is to show ads if a visitor isn't from the UK and it works fine on the dynamic pages. This one I want it on now as well is plain dead static html. So yes I can create a file which queries the database but... 1) How do I get the visitor's IP from the html page to the php script and... 2) How do I get the decision from my PHP page (as to whether or not displaying ads) back to the html page and subsequently displaying it. Javascript, in my imagination, is the only possible way but I don't know if it can be done. The tracking system just works one way - pull an img from their server and they know all stat because the visitors pulls it straight from their server. But htis requires a two-way operation. Any ideas?
Use the image functions in PHP to spit out the image. That way all you have to do is use a normal IMG tag (doesn't matter if the page is static or dynamic). Within PHP you can see the IP address of the person making the request for the image file.
Yeah the PHP part of it isn't the problem. I'll mess around with it over the weekend if I get the time. i don't want to show the actual img though, just use it as a way to transfer data, let javascript evaluate it and then decide on outputting AdSense code or not. So no img will be shown. I'll try it out. Thanks for helping (I'm bound to get back here though).
Search Google for geotargetting database, I'm sure you will get lots of places that sell them (in natural results and AdWord advertisers).