1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to Geo-Target or redirect people from different countries?

Discussion in 'CPA' started by gialappas, Jun 10, 2011.

  1. gialappas

    gialappas Regular Member

    Joined:
    Jan 25, 2010
    Messages:
    263
    Likes Received:
    180
    Hello,

    I'm promoting a US offer, but I'm also receiving a ton of traffic from about 5 other countries worth monetizing.

    How can I geo-target those 5 countries or re-direct them to a separate page? Is there a script out there or what is the most efficient way to do something like this?

    Your help is greatly appreciated!
     
  2. Checkmate

    Checkmate Elite Member

    Joined:
    Aug 9, 2010
    Messages:
    1,536
    Likes Received:
    639
  3. gialappas

    gialappas Regular Member

    Joined:
    Jan 25, 2010
    Messages:
    263
    Likes Received:
    180
    Thanks! Unfortunately I did not practice with the php. I do not know to create a page. is this correct syntax?


    HTML:
    
    <?php
    function visitorCountry() {      $ip = getenv('REMOTE_ADDR');     $d = file_get_contents(         "http://www.ipinfodb.com/ip_query_country.php?ip=$ip&output=xml");      //Use backup server if cannot make a connection     if (!$d) {         $backup = file_get_contents(             "http://backup.ipinfodb.com/ip_query.php?ip=$ip&output=xml");          $answer = new SimpleXMLElement($backup);          if (!$backup)             return false; // Failed to open connection      } else {         $answer = new SimpleXMLElement($d);     }     return $answer->CountryCode; }
    $sCountryFrom = visitorCountry(); if ( $sCountryFrom == 'US' ) {     header('Location: /index.php');     exit(0); }
    if ( $sCountryFrom == 'DE' ) {     // serve German content template if they are from Germany      $cSmarty->display('/index_de.php'); } else {     // serve English to everyone else     $cSmarty->display('/index_other.php'); }
    ?>