New Posts
Welcome guest, is this your first visit?
  • Login:
TruePoker.eu Affiliate Program
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Senior Member
    www.theaffiliatelife.com
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    England
    Posts
    1,604
    Blog Entries
    6
    Feedback Score
    32 (100%)

    Default Geo Targetting with PHP

    Hi there,

    I'm looking to do a bit of basic Geo Targetting in a straight forward PHP site (so no WP plugins allowed).

    I've been trying to get an idea of the functions that I'm going to need by looking through PHP.net.

    I've come across the function geoip_country_name_by_name()

    Is this going to do the job correctly for me though? Or should I be using another function to determine's a vistor's geographical location.

    Also, is it possible to tell a user's operating system through PHP as well?

    Cheers,
    If you liked my post, you might also like:

    Affiliate Blog: The Affiliate Life
    Twitter Feed: twitter.com/shortstackgames
    Facebook: facebook.com/shortstacksimon
    Pinterest: pinterest.com/slotgames

    Latest blog post: Actioning those ideas which will take your business to the next level

  2. #2
    Formerly TPB
    My Status
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    Wales
    Posts
    672
    Feedback Score
    16 (100%)

    Default

    Quote Originally Posted by TheShortStack View Post
    Hi there,

    I'm looking to do a bit of basic Geo Targetting in a straight forward PHP site (so no WP plugins allowed).

    I've been trying to get an idea of the functions that I'm going to need by looking through PHP.net.

    I've come across the function geoip_country_name_by_name()

    Is this going to do the job correctly for me though? Or should I be using another function to determine's a vistor's geographical location.
    I'm pretty sure you need to use a database (like Maxmind) along with some PHP to use geotargeting, not just PHP on its own.

    I'm not great with PHP though so I can't expand on that.

    Quote Originally Posted by TheShortStack View Post
    Also, is it possible to tell a user's operating system through PHP as well?
    This is what I started with:

    Detect operating system from user agent string (PHP Code) • Geekpedia

  3. #3
    Senior Member
    My Status
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    USA
    Posts
    490
    Blog Entries
    1
    Feedback Score
    44 (100%)

    Default

    As far as I know you can get the IP (I used function getip() in my script) from your visitor, but then have to find location from that.

    I used:
    IP address geolocation SQL database :: IPInfoDB

    I created a geo-target script for a dating site banner. I did this many months back, and decided not to use the code.

    I dont remember clearly how I did it.


    Store Your Data in The Cloud and Access it Wherever You Are.
    Try Just Cloud Today for FREE

  4. #4
    #!/usr/bin/mikebrad
    My Status
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    USA
    Posts
    912
    Feedback Score
    10 (100%)

    Default

    On maxmind's webste, download GeoIP.dat and geoip.inc. Since you already named one of their functions, I'll assume you did this already.

    To get the country code (US, CAN, UK, etc), use the following code:

    PHP Code:
    $gi geoip_open("/your/absolute/path/to/GeoIP.dat",GEOIP_STANDARD);
    global 
    $country;
    $country geoip_country_code_by_addr($gi$_SERVER['REMOTE_ADDR']);
    geoip_close($gi); 
    The variable $country will contain the country code.

    From there, you just use a simple if statement like:

    PHP Code:
    if ($country == 'US') {
    //US ONLY
    } elseif ($country == 'UK') {
    //UK ONLY
    } else {
    //EVERYONE ELSE


  5. #5
    Senior Member
    www.theaffiliatelife.com
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    England
    Posts
    1,604
    Blog Entries
    6
    Feedback Score
    32 (100%)

    Default

    Thanks guys - I'll give it a go
    If you liked my post, you might also like:

    Affiliate Blog: The Affiliate Life
    Twitter Feed: twitter.com/shortstackgames
    Facebook: facebook.com/shortstacksimon
    Pinterest: pinterest.com/slotgames

    Latest blog post: Actioning those ideas which will take your business to the next level

  6. #6
    Senior Member
    www.theaffiliatelife.com
     
    ----
     

    Add as a friend
    Join Date
    Nov 2008
    Location
    England
    Posts
    1,604
    Blog Entries
    6
    Feedback Score
    32 (100%)

    Default

    Ok, quick question about this.

    Mike, when you say I need to put my absolute path to the GeoIP.dat - how does that work.

    If the .dat file is installed on the root of onlinepoker.com, and I'm trying to insert the code into /include/header.php how does that translate into the PHP code?

    Should the code read:
    PHP Code:
    $gi geoip_open("../GeoIP.dat",GEOIP_STANDARD); 
    Any thoughts or suggestions would be really welcome given that that code seems to be giving me an error message
    If you liked my post, you might also like:

    Affiliate Blog: The Affiliate Life
    Twitter Feed: twitter.com/shortstackgames
    Facebook: facebook.com/shortstacksimon
    Pinterest: pinterest.com/slotgames

    Latest blog post: Actioning those ideas which will take your business to the next level


 

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Specific Event Targetting
    By doovde in forum Sportsbook Affiliate Forum
    Replies: 1
    Last Post: 02-12-2010, 07:50 AM
  2. Carribean Poker Worth Targetting?
    By PokerFelts in forum New Affiliate Questions & Answers
    Replies: 7
    Last Post: 11-04-2009, 09:51 PM
  3. Geo Targetting plugin for WP
    By TheShortStack in forum Wordpress - Web Design - Coding - Technical
    Replies: 2
    Last Post: 02-02-2009, 05:48 AM
  4. How do I test my Geo Targetting?
    By TheShortStack in forum General Poker Affiliate Forum
    Replies: 17
    Last Post: 01-06-2009, 10:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Powered by vBulletin® Version 4.1.5
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0