monetizer expertmobi
Dismiss Notice
Welcome to Our Community
Wanting to join the rest of our members? Feel free to sign up today.

[Tut + Code][GET] Free Geo-Target Redirect Script [Noob-Friendly]

Discussion in 'General Affiliate Marketing Forum' started by Hacder, Nov 19, 2012.

  1. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    Hey fellow members,

    I know this kind of scripts have been posted before on various forums and maybe here as well, but i have seen many people (Specially newbies) struggling to get it working properly because of if/else statements confusing them and not easy as this one.

    So i decided to code an easier and more optimized version for y'all using MaxMind's JS API. :)

    For people who're wondering what you can do with this script, Let me tell you this, you can use this script with your CPA campaigns or just any campaign and drive/filter targeted traffic to your offers/landing pages. Just think about how much extra $$ you could make from the rest of your traffic which might have been going waste.

    Here's one scenario for you to understand why you need to use geo-redirecting script:
    Lets say you have a facebook page and you're promoting some US targeted offer by posting your landing page URL, Your fans will start visiting your URL and since the offer is limited to US visitors, Others will not be able to complete your offer and end up going to some other page which is filtered by either the CPA network or the advertiser. So? You make nothing out of these potential visitors.

    To fix that and to make that extra bill, You need to use geo-redirecting script. Using this script, you can easily filter geo-targeted traffic and make tons more from other offers or landing pages.

    Now to get started, All you have to do is add your targeted country's "ISO 3166-1 - Alpha-2" code and redirect URL to the "target" array object. (Format: CountryCode = Redirect URL).
    ISO 3166-1 - Alpha-2 Codes list can be found here (See Column: "Alpha-2 Code" for country code of the country you want to target).

    So for this example, I'll target 3 countries, i.e. "US" (United States), "GB" (United Kingdom) and "CA" (Canada).

    Alright, Now that we have the country codes of our targeted countries, We just have to specify the country code and the redirect URL to our "target" array object.

    In this format:
    Code:
    target['CountryCode'] = "RedirectURL";
    So for our targeted countries "US" (United States), "GB" (United Kingdom) and "CA" (Canada), The code will be:
    Code:
        target['US'] = "http://domain.tlds/my-us-offer/";
        target['GB'] = "http://domain.tlds/my-uk-offer/"; 
        target['CA'] = "http://domain.tlds/my-ca-offer/";
    
    And for non-targeted/other visitors, you have to specify the URL for "All" key.
    That is:
    Code:
    target['All'] = "http://domain.tlds/non-targeted-visitors-page/";
    
    Here's the the full code:
    Code:
    <script src="//j.maxmind.com/app/geoip.js" charset="ISO-8859-1" type="text/javascript"></script>
    <script>
        var target = new Array(); // Target Array, Don't remove this.
    
        // Here's an example which redirects visitors to your specified URL for your targeted country code:
    
        target['All'] = "http://domain.tlds/non-targeted-visitors-page/"; // Redirects non-targeted/other visitors to this URL.
        target['US'] = "http://domain.tlds/my-us-offer/"; // Redirects' "US" (United States) Visitors to this URL.
        target['GB'] = "http://domain.tlds/my-uk-offer/"; // Redirects' "GB" (United Kingdom) Visitors to this URL.
        target['CA'] = "http://domain.tlds/my-ca-offer/"; // Redirects' "CA" (Canada) Visitors to this URL.
    
        /* == DON'T EDIT THE BELOW CODE == */
        	var visitorCountryCode = geoip_country_code();
        	var redirectURL = target[visitorCountryCode];
        	if(redirectURL == null) redirectURL = target['All'];
        	if(redirectURL) window.top.location.href = redirectURL;
        /* == DON'T EDIT THE ABOVE CODE == */
    </script>‚Äč
    
    So you can just copy-paste the above code in some html file and start driving targeted traffic to your offers/landing pages.

    I hope this helps you all. Any questions/help, post here and I'll try my best to help you out :)

    Note: This code has been tested with latest versions of chrome and firefox browsers, I don't use other browsers, So if it doesn't work, let me know.

    Also, If you like the script, Please post so the thread can stay alive and others benefit ;)

    @Mods/Admin:Sorry, If this is not the right section for this thread, but i think this will be useful for everyone doing CPA campaigns (So i posted here). Please move to the appropriate section if required, Thanks! :)

    Edit: Updated Maxmind API Script with the working version, previous link was removed/dead for some reason.
     
    Last edited: Mar 23, 2014
  2. monetizer
  3. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    230+ Views and Still empty? hmm..Weird.
     
  4. alxwanted6k

    alxwanted6k Affiliate affiliate

    34
    6
    8
    thanks for this post :)
     
  5. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    My pleasure :)
    Will create another thread with codes to filter out shitty traffic (With any county code).

    Hope people like my stuff :D
     
  6. lokiys

    lokiys Get your fix Ninja! affiliate

    997
    31
    28
    Saw this in BHW as well. Is it your script ?
     
  7. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    Yep! Its my script and I had posted on BHW as well (Different username, PM me if you want to confirm) ;)
     
  8. lokiys

    lokiys Get your fix Ninja! affiliate

    997
    31
    28
    Nop no worries just asked.
    Good stuff.
     
  9. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
  10. lokiys

    lokiys Get your fix Ninja! affiliate

    997
    31
    28
    Remembered - checked some time ago script or plugin for wordpress for like when users coming from www.domain1.com then in stats i can see that this user comes from www.domain1.com (referrer) and it is from US - UK etc. maybe something more can add but this what i did not find :)
     
  11. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    Well if you know coding, You can easily combine this into your other scripts and make a more powerful tool, But this is just for quick targeting :p
     
  12. realsoftwaredevelopment

    realsoftwaredevelopment Affiliate affiliate

    13
    0
    0
    Yeah i saw this on BHW... its a good script :)
     
  13. skypigeon

    skypigeon Affiliate affiliate

    43
    1
    0
    ITS NOW working for i copied it on a notepad and save it as html didnt work for my country...
     
  14. tech405

    tech405 Affiliate affiliate

    3
    0
    0
    Thanks Hacder! This is exactly what i was looking for. I tweaked it for my needs just in case someone wanted to hide their referral link... just "blankrefer.com/?" to infront of the offer url
     
  15. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    Yeah I only posted there ;)


    Sent from my iPhone using Tapatalk
     
  16. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    What is not working for you?


    Sent from my iPhone using Tapatalk
     
  17. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    My pleasure mate. And that's a good tweak btw :D


    Sent from my iPhone using Tapatalk
     
  18. youngmoney2

    youngmoney2 Affiliate affiliate

    2
    0
    0
    Hi Hacder,

    Thanks for the script.

    I am just wondering though, I am trying to get it to work for other countries and not just US, GB and CA. How do I add more countries in that I would like to target like AUS, IRE, NZ etc?

    Thanks
     
  19. youngmoney2

    youngmoney2 Affiliate affiliate

    2
    0
    0
    Hi Hacder,

    Never mind I just figured it out why it wasn't working, I had Australia as AUS for the code and it needed to be AU.

    All good :)
     
  20. Hacder

    Hacder Affiliate affiliate

    83
    13
    8
    Great. Let me know if you have any questions or need any help :)


    Sent from my iPhone using Tapatalk
     
  21. crysper

    crysper Moderator moderator Service Manager affiliate

    T J Tutor likes this.

Featured Resources (View All)

MI