Preview Openx geotargeting for different countries

Openx is an open source ad server. If you have more than one website or simply want a flexible system for targeting your ads to the right audience, it's worth a look. One of many  features is the built-in Geotargeting plugin.

Of course, after adding local ads to your database, you want to have a look at what the page looks like for a visitor from a different country. It took me some time to figure out a way. But I found a good method for getting a preview for a different country. In openx version 2.6 you can edit the file /plugins/geotargeting/GeoIP/ at line 141. At the end of the OA_Geo_GeoIP_unpackCookie function, add something like

<?php    if ($_SERVER['REMOTE_ADDR'] == 'HERE.IS.YOUR.IP') { // insert your IP
        $aGeoInfo['country_code'] = 'ES'; // insert country code
    return $aGeoInfo;
That's all, no proxies or messing with your tags or sites required. I hope a similar feature will be added to the plugin sometime in the future. Oh, and I'm not quite sure what would happen if cookies are disabled, but who cares, this is just for testing.


  1. avatar
    wrote this comment on

    Thank you very much, it's very usefull to test some of the advertisement.

    But in my version of openx, 2.6.4, the name of the function to modify is OA_Geo_GeoIP_unpackCookie.


    1. avatar
      wrote this comment on

      Hi Vincent... but I wrote OA_Geo_GeoIP_unpackCookie in my post!? I'm a little confused what you mean.

Start a new thread

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.