Sam
Sam

Reputation:

Display content based on location

How do I go about displaying content based on a users location ? For ex. If somebody accesses the site from the New York , I would like to display New York Hotels . However if somebody accesses the site from Chicago , I would like to display Chicago hotels.

Upvotes: 0

Views: 11029

Answers (4)

wezell
wezell

Reputation: 573

dotCMS offers the ability to geolocate content OTB (disclaimer, I work for them). You can see a demonstration that displays news content based on the user's location onthe demo site:

It is pretty easy to setup and use. Any type of content can be geolocated and the content can be accessed through the RESTful API. Under the covers, the Geolocation queries are handled natively via Elasticsearch.

Example: http://demo.dotcms.com/demos/content-geolocation

Docs: http://dotcms.com/docs/latest/es-geolocation-queries

Upvotes: 0

Michael Lynn
Michael Lynn

Reputation: 62

This is the exact reason I created wpgeocode. WPGeocode is a free plugin for wordpress that enables publishers to customize content based on reader location. Check out the plugin at the support site at http://www.wpgeocode.com

The plugin enables shortcodes that can be placed in your posts or pages. There are many conditional shortcodes such as [wpgc_is_country_code country_code="US"] for this exact purpose. Simple open the shortcode, specify the target country_code and provide the content to be displayed if the reader is visiting from that specific country.

Visit http://www.wpgeocode.com/shortcodes for a complete listing - here are a few:

  • [wpgc_is_city_and_state city=”Yardley” state_code=”PA”]
  • [wpgc_is_ip” ip=”xx.xx.xx.xx”]
  • [wpgc_is_ips” ip=”xx.xx.xx.xx,aa.bb.cc.dd”]
  • [wpgc_is_not_ip” ip=”xx.xx.xx.xx”]
  • [wpgc_is_not_ips” ip=”xx.xx.xx.xx,aa.bb.cc.dd”]
  • [wpgc_is_city” city=””]
  • [wpgc_is_cities” cities=”city one,city two,city three”]
  • [wpgc_is_not_city” city=””]
  • [wpgc_is_not_cities” cities=”city one,city two,city three”]
  • [wpgc_is_nearby”] – Uses the value you specify in the Nearby Range setting from the administrative panel
  • [wpgc_is_not_nearby”]
  • [wpgc_is_within” miles=”10″]
  • [wpgc_is_within kilometers=”12″]
  • [wpgc_is_country_name” country_name=””]

  • [wpgc_is_country_names” country_name=”United States,Egypt,Albania”]

  • [wpgc_is_country_code” country_code=””]
  • [wpgc_is_country_codes” country_codes=”US,GB,AZ”]
  • [wpgc_is_state_code” state_code=””]
  • [wpgc_is_state_codes” state_codes=”PA,NJ,TX”]
  • [wpgc_is_not_country_name” country_name=””]
  • [wpgc_is_not_country_names” country_names=”United States,Egypt,Albania”]
  • [wpgc_is_not_country_code” country_code=””]
  • [wpgc_is_not_country_codes” country_codes=”US,GB,AZ”]
  • [wpgc_is_not_state_code” state_code=””]
  • [wpgc_is_not_state_codes” state_codes=”PA,NJ,TX”]

Upvotes: 0

Mattias
Mattias

Reputation: 9471

You need some database/api with information about hotells in different locations, then you need to now where the visitor is.

You can use something like Travel/Hotel API's? to find hotells.

And for finding the location of your visitor you can use something like http://www.hostip.info/use.html or you can use HTML5 geolocation api example http://html5demos.com/geo . The bad thing with the html5 geo api is that the user need to accept before you get their location.

Remember that there is no guaranty that the location is correct...

Upvotes: 0

toomanyairmiles
toomanyairmiles

Reputation: 6485

You're looking for a Geoloction database which would give you access to the typical IP ranges for the countries/cities you need to flag.

This is not absolute or completely trustworthy information though. Country level geo-location is mostly effective but anything like city/state/zip code level information should be treated with great caution.

I've worked with major multinational media providers using expensive paid services and discovered that the information in these databases is a very long way from correct and that users individual circumstances often prevent geo-location from being effective.

e.g. Virgin and East Coast trains in the UK use T-Mobile Germany as their onboard internet provider so you appear to be in Germany to many sites and payment processors.

There are quite a few free geolocation databases, MaxMind springs to mind (though this is not a recommendation of their service).

You can find some thoughts on implementing geo-location here

Upvotes: 1

Related Questions