Help- Javascript for changing location on LP

by Udt
3 replies
Hey guys,

Not sure if this went in the programming forum or in the CPA forum but since I am doing it for CPA, I decided to ask in this. Does anybody know where to get the javascript to detect the users location and change it on the landing page? So for example if visitor A is from boston, MA, it would say boston, MA on the landing page? I didn't know if that was like a "public" code or if we had to pay for it to have somebody make it. Thanks in advance!

D
#changing #javascript #location
  • Profile picture of the author mywebwork
    I believe you are speaking about "geocode", I've used it on several of my websites to detect the visitors country and direct them the country-specific site.

    A couple of links for you to explore:

    geocode (geocode) - PHP Classes

    This is a PHP class (which I have used before) to handle the basic coding.

    Geocoding Addresses with PHP/MySQL - Google Maps API - Google Code

    This is an article about using the Google Maps API to do essentially the same thing.

    Bill
    {{ DiscussionBoard.errors[1552274].message }}
  • Profile picture of the author MemberWing
    If you use JQuery loaded from Google servers - there are some variables available that include geolocation info.

    Gleb
    {{ DiscussionBoard.errors[1552373].message }}
  • Profile picture of the author Fors
    I believe this is what you are looking for:

    <script language="JavaScript" src="http://j.maxmind.com/app/geoip.js"></script><script language="JavaScript">document.write(geoip_region_ name());</script>

    It grabs the proper javascript code and automatically shows your city based on ip

    Try it !

    Edit: My apologies, that script only writes out the state, it needs some changes to write out city too. Search for maxmind geoip and you'll probably find it fast though.
    {{ DiscussionBoard.errors[1552924].message }}

Trending Topics