Redirect users based on their states using maxmind API

Sometimes when promoting CPA campaigns on PPV i create separate landing pages targeting different states in the US for example when i was promoting Obama CPA Offer back in days of US presidential election i create separate landing pages for all major and states  and targeted them with those landing pages .

I am going to share with you guys code using which you can make it possible to redirect users based on their states ,

 

<script language="JavaScript" src="https://j.maxmind.com/app/geoip.js"></script>

<script language="JavaScript">

var user_state = geoip_region();

if( user_state == "NY")
window.location = "https://www.kjrocker.com/";

else if( user_state == "TX")
window.location = "http://rockerinteractive.com/";

else
window.location = "http://google.com/";

</script>

The above script will redirect visitors from New York state to KJ Rocker Blog and Visitors from Texas to  Rocker Interactive  And all other traffic will be redirected to google.com you can easily add more states by copying and pasting else if part and add as many states as you want (don`t forget to replace state codes with your targeted states , you can find all state/region codes in US here .   Tracking such campaigns with prosper  is a headache so i would recommend you to use CPVLAB for tracking such campaigns (find $50 off on cpvlab coupon here ,

About The Author

you're currently offline

Scroll to Top

By continuing to use the site, you agree to the use of cookies. Privacy Policy

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" then you are consenting to this.

Close