How Do You Make A Person's City Show On Your Site?

12 replies
I'm wanting to learn the script code to make a person's city show on my webpages.

For example it might say "MAKE MONEY IN "YOUR CITY" or "HOW X NUMBER OF PEOPLE LOST WEIGHT IN "YOUR CITY" THIS MONTH!

I think you guys get my drift.

If anybody knows the code to do this that would be awesome!
#city #make #person #show #site
  • Profile picture of the author SteveSRS
    Hi,

    You need a product like IP2Location or GEO-ip.
    You could also do it for free but those solution will really slow down your site and I would not recommend that.

    Either way some programming know-how is needed.

    I've always been using ip2location but I'm annoyed with them because they don't accept Paypal.
    {{ DiscussionBoard.errors[6455251].message }}
  • Profile picture of the author botninja
    Try an IP to City lookup site with an API - I have used this one in the past: ipinfodb.com/ip_location_api.php and it works most of the time.

    You will have to put a check in there so if no city name is returned you put something like 'your'

    If you need a hand doing it give me a shout
    Signature
    Need something automated? Take a look at The Bot Shop
    {{ DiscussionBoard.errors[6455624].message }}
  • Profile picture of the author John Ayling
    I've used MaxMind Geo IP - the free version - which works great with PHP.
    http://www.maxmind.com/app/geolite

    Takes a bit of setting up, but the benefit is that it does not use an external call to a web service but looks up a data file instead on your server.

    This is how I set it up after I downloaded the files from MaxMind

    1. Create a directory in the root of your domain called geoip-directory.
    In this folder put the GeoIP.dat file and the geoip.inc file

    2. Then in the page that you want to get the country code - put this code

    Code:
     
    $dir_temp = dirname(__FILE__);
        require($dir_temp.'/geoip-directory/geoip.inc');
        $gi = geoip_open($dir_temp.'/geoip-directory/geoip.dat',GEOIP_STANDARD);
        $geoip_ip = $_SERVER['REMOTE_ADDR'];    
        $countryCode = geoip_country_code_by_addr($gi,$geoip_ip);    
        geoip_close($gi);    
        unset($dir_temp,$geoip_ip,$gi);
    This gets the country code and puts it into the php variable $countryCode.

    You can make a similar call to get the region and/or city but that's where they may be charging for more specific types of databases.

    Hope this helps.
    John
    Signature
    Software Marketing & Licensing System for WordPress Plugins, Themes & .NET Software
    >> 72 Hour Special <<
    {{ DiscussionBoard.errors[6475307].message }}
    • Profile picture of the author josh1az
      Hi

      where do I get the GeoIP.dat file and the geoip.inc file
      from?

      thx
      {{ DiscussionBoard.errors[9562618].message }}
  • Profile picture of the author cpaunit
    the solution john give is what you want
    Signature
    http://www.cpaunit.com
    Searching Host & Post Offers to Promote
    {{ DiscussionBoard.errors[6477888].message }}
  • Profile picture of the author SteveSRS
    What john said is the GEO-ip I mentioned.

    There is actually a better method of using GEO-ip (also available for ip2location) as he mentioned but a bit more technical. That is installing it as mod for apache2. This is the fastest and least memory intensive. You would just have the data available in global server variable like $_SERVER['GEOIP_COUNTY'SHORT] etc
    {{ DiscussionBoard.errors[6481127].message }}
  • Profile picture of the author Lovelogic
    Why not just pass the city name in the URL..

    eg: mysite.com/wieght_loss_promo.php?city=xxxxxxxxx

    or if one wants to get a little more fancy use the htaccess file to rewrite & redirect so the URL looks like mysite.com/wieght_loss_promo/chicago

    Then just add all the variations to the sitemap and let Google chew away. As the search engine results will suggest the most relevent link to a potential visitor based upon their search criteria you don't have to figure out where they are using the IP address.
    {{ DiscussionBoard.errors[6484630].message }}
    • Profile picture of the author mojojuju
      Originally Posted by Lovelogic View Post

      Why not just pass the city name in the URL..
      Pass the city name of the visitor in the URL? Where are you going to get the visitor's city name if you're not using one of the solutions suggested above?

      Originally Posted by Lovelogic View Post

      eg: mysite.com/wieght_loss_promo.php?city=xxxxxxxxx

      or if one wants to get a little more fancy use the htaccess file to rewrite & redirect so the URL looks like mysite.com/wieght_loss_promo/chicago

      Then just add all the variations to the sitemap and let Google chew away.
      Perhaps you're suggesting that a page be made ahead of time for each city? Consier that the GeoIPCity database from Maxmind contains 353,223 cities. If you wanted, you could create 353,223 pages, one for each city. But what would Google "think" about there being 353,223 nearly identical pages residing on one server?


      Originally Posted by Lovelogic View Post

      As the search engine results will suggest the most relevent link to a potential visitor based upon their search criteria you don't have to figure out where they are using the IP address.
      It doesn't work like that - not unless a person is searching for the terms "weight loss" along with a specified location.

      For instance, I live in the midwestern United States. Google knows the city where I live. But if I search for "local plumbers", the top result is not a plumber in my area. It is a site that allows people to search for plumbers nationwide. The next result is a plumbing business in Los Angeles, California. That's just about 2,000 miles from here...

      Also, your idea doesn't take into consideration visitors that don't arrive from Google.

      Maxmind's product is excellent. Their free GeoLiteCity database gives better results than some of the paid services I've tried.
      Signature

      :)

      {{ DiscussionBoard.errors[6485013].message }}
      • Profile picture of the author Lovelogic
        Originally Posted by mojojuju View Post

        Pass the city name of the visitor in the URL? Where are you going to get the visitor's city name if you're not using one of the solutions suggested above?

        If you wanted, you could create 353,223 pages, one for each city. But what would Google "think" about there being 353,223 nearly identical pages residing on one server?

        It doesn't work like that - not unless a person is searching for the terms "weight loss" along with a specified location.
        Answers in reverse order...

        The OP wanted pages that were geo-targeted
        so that implies the users have provided a location as part of the search criteria (or have been sufficiently profiled by Google to know where they live) . Know thy users anybody looking for a face 2 face support group, diet club or gym are looking for a physical place and will keep drilling down till they find somewhere that appears to be geographically local. The same as you would do if looking for an emergency plumber !

        353,223 pages ? I'd hate to see your code..
        I'd use ONE PAGE, randomise the testamonial quotes, images and membership numbers (if you wanted to get really creative automatically scrape the local news for heart attack and other generally obese stories and include them server side to give each variation a more individual flavour ). As I stated previously pass the name into the page via a URL variable and use that to insert the city name into the page at strategiec locations. eg: meta description, H1 and first content paragraph. So Google sees what it expects to see.. a large network or club with regional variations. No two pages are identical and even a curious visitor looking at several locations would probably not realise it's all smoke & mirrors just to carry some cheesy pop-up advert.

        Google will index all the URL variations it can find
        by reading the sitemap and one page can have many faces. Such behaviour is perfectly normal for many websites.
        http://mysite.com/wieght_loss.php?c=chicago
        http://mysite.com/wieght_loss.php?c=new york
        http://mysite.com/wieght_loss.php?c=houston
        typing all these in by hand is a chore so I'd normally use a simple PHP script to read a list of towns and build the rest of the XML document in a matter of seconds
        When the prospective visitor runs a search they will be shown what the search engine considers to be relevent links based upon what it thinks the users location is. That's half the geolocation done. Ultimately it's the visitors choice so when they click the link+city variable that is most relevent to them they have told you where or rather what location they are interested in. Either way they are onsite.
        {{ DiscussionBoard.errors[6494865].message }}
        • Profile picture of the author mojojuju
          Originally Posted by Lovelogic View Post

          Answers in reverse order...

          The OP wanted pages that were geo-targeted
          so that implies the users have provided a location as part of the search criteria (or have been sufficiently profiled by Google to know where they live) . Know thy users anybody looking for a face 2 face support group, diet club or gym are looking for a physical place and will keep drilling down till they find somewhere that appears to be geographically local. The same as you would do if looking for an emergency plumber !
          The OP said "I'm wanting to learn the script code to make a person's city show on my webpages."

          Originally Posted by Lovelogic View Post

          [B]353,223 pages ?
          Yes, 353,223 pages would need to be generated if you want 353,223 pages indexed by Google which represent each of 353,223 cities. The same could be done with 100,000 cities or 10 cities.... Whatever number of cities are chosen, using the method proposed by yourself would require that Google have a page indexed for each city you'd want to represent.

          Originally Posted by Lovelogic View Post

          I'd hate to see your code..
          Why would you hate to see code which accomplishes the solution you've proposed?

          Originally Posted by Lovelogic View Post

          I'd use ONE PAGE, randomise the testamonial quotes, images and membership numbers (if you wanted to get really creative automatically scrape the local news for heart attack and other generally obese stories and include them server side to give each variation a more individual flavour ). As I stated previously pass the name into the page via a URL variable and use that to insert the city name into the page at strategiec locations. eg: meta description, H1 and first content paragraph. So Google sees what it expects to see.. a large network or club with regional variations. No two pages are identical and even a curious visitor looking at several locations would probably not realise it's all smoke & mirrors just to carry some cheesy pop-up advert.

          Google will index all the URL variations it can find
          by reading the sitemap and one page can have many faces. Such behaviour is perfectly normal for many websites.
          http://mysite.com/wieght_loss.php?c=chicago
          http://mysite.com/wieght_loss.php?c=new york
          http://mysite.com/wieght_loss.php?c=houston
          typing all these in by hand is a chore so I'd normally use a simple PHP script to read a list of towns and build the rest of the XML document in a matter of seconds
          When the prospective visitor runs a search they will be shown what the search engine considers to be relevent links based upon what it thinks the users location is. That's half the geolocation done. Ultimately it's the visitors choice so when they click the link+city variable that is most relevent to them they have told you where or rather what location they are interested in. Either way they are onsite.
          Great! And bonus points for proposing that a script be used to create sitemap with a list of pages for each town instead of typing them in manually! That's brilliant because using a computer to perform repetitive tasks is something that nobody has ever thought of. :rolleyes:

          Your solution though, still depends on search engines determining a visitors location, an idea which isn't reliable. Also consider that not all people may arrive at OP's page from a search engine.
          Signature

          :)

          {{ DiscussionBoard.errors[6494960].message }}
  • Profile picture of the author leorocking25
    [DELETED]
    {{ DiscussionBoard.errors[6488520].message }}
    • Profile picture of the author mojojuju
      Originally Posted by leorocking25 View Post

      It will be safe and more flexible to use php codes than to using any products that will show the location of the users of your site.
      What "php codes" could show a user's location without using an IP/Location product?
      Signature

      :)

      {{ DiscussionBoard.errors[6488606].message }}

Trending Topics