Redirect users based on their states using maxmind API

Share love!

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 ,


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 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 Kj Rocker

Hi there my name is KJ and I am the owner of KJ Rocker Blog And C.E.O KJ Rocker F.Z.E . I am an affiliate marketer, and online marketing consultant living Dubai Life. My biggest achievement is not only turning my affiliate life dream into reality, but also i have helped many others through my coaching program to achieve success.
Want to be successful ? Follow me on twitter or join myFacebook group to find out more!


  1. Thanks, this script useful.

    Does the same could be done with countries?

  2. Yes it can be 🙂

  3. Hi,

    I’m wondering, is there a limit to the number of calls you can make using this technique?

    I have a site where I might need to redirect 200k people in the US per month based on their State – would I need to pay for an enhanced service from maxmind, with such large numbers, or would your code still work ok?

    Many thanks in advance!

  4. Hi it should work fine ..

  5. Hi,

    This worked liked a dream up until recently, but stopped working now – the maxmind web address now serves up a 404 error.

    Wondering if they stopped this free service? If there is an alternative?

  6. hey they no more offer free service, its gone paid ..No authentic alternative so far…

  7. Hi,

    Thanks for getting back to me so quickly. Ah, shame it’s gone. Does your code still work if I pay and use the following geoip2 line in the code, instead of the legacy geoip one you were using:

    Or is it now a bit more complex than that?

    I looked at their website (don’t mind paying), but their code looks way too complex for me and yours was so beautifully simple to implement…