CPAElites 2021 is coming! Finally! No more excuses! - Please click [here] to read more!
CPAElites 2021 beta: Get access to the CPAElites 2021 closed beta now! - Please click [here] to get access!


Geo-IP onClick redirect
2016-03-14, 12:20 AM,
#1
Hello, I try for the last hours to get a onClick geo-ip redirect that I can use for my wordpress site. Basically when a US person click the "Download" he should go to English LP, when a FR clicks, to FR LP and so on. All scripts that I find redirect on page load, I want on click.

Here is what I found but can't make it work.

PHP Code:
<?php
$country_code 
$_SERVER["HTTP_CF_IPCOUNTRY"];
if (
$country_code=="UK") {
$link 'Insert UK Link';
}
elseif (
$country_code=="FR") {
$link 'Insert France Link';
}
elseif (
$country_code=="DE") {
$link 'Insert Germany Link';
}
else {
$link 'Insert Default Link';
}
header("location:$link");
exit;
?>

Basically I want the <a href = "http://mylanding.com" /a> to change according to country.
Reply
2016-03-14, 12:29 AM,
#2
Reply
2016-03-14, 07:04 AM,
#3
Link Cloaker WordPress plugin does this for you.


Reply
2016-05-03, 09:44 PM,
#4
It worked ?

/20 charact
Reply
2016-05-05, 05:00 AM,
#5
obviously its not going to work lol how would it know which country the user is coming from?
need to use an API to get the country
you can use old maxmind geoip database if you google for it
Reply
2016-05-05, 11:10 AM,
#6
(2016-05-03, 09:44 PM)Wolfz Wrote: It worked ?

/20 charact

Nope, answer is below:

(2016-05-05, 05:00 AM)lancerimpact Wrote: obviously its not going to work lol how would it know which country the user is coming from?
need to use an API to get the country
you can use old maxmind geoip database if you google for it
Reply
2016-05-05, 04:31 PM,
#7
Let's assume that HTTP_CF_IPCOUNTRY (it seems it's CloudFlare only param) returns you a country code.

PHP Code:
$countryCode $_SERVER["HTTP_CF_IPCOUNTRY"];

$link 'http://example.link';
switch (
$countryCode) {
    case 
'UK':
        
$link 'http://example.link/uk';
        break;
    case 
'FR':
        
$link 'http://example.link/fr';
        break;
    case 
'DE':
        
$link 'http://example.link/de';
        break;
}

/* You do this if let's say you have  a link in your html which says Download and it points to this script and when user clicks it he will be redirected to localized download page*/
header("location:" $link);
exit;

/* or you echo it in your html if you want user to only see the localized link without any redirects */
echo '<a href="'.$link.'">Download</a>'
Reply
2016-05-10, 12:31 AM,
#8
"You do this if let's say you have a link in your html which says Download and it points to this script and when user clicks it he will be redirected to localized download page."

Exactly my case.
Reply
2016-05-10, 02:39 PM,
#9
or you can try this link shortener for country redirect. they also have mobile redirect too.
https://manage.smarturl.it/
Reply


Related Threads
Thread Author Replies Views Last Post
  Setting up OnClick event in ClickFunnels. How? SupremeWarrior 1 147 2020-11-24, 10:32 PM
Last Post: DrKent
  Onclick OR direct content locker? SupremeWarrior 1 153 2020-11-17, 08:10 PM
Last Post: DrKent
  How to redirect user after completing survey with cpa build mathewocomy 1 291 2020-06-16, 02:31 AM
Last Post: DrKent
  How Redirect Locker based on ip address ? ned02 1 467 2020-05-18, 03:53 PM
Last Post: Antonio
  which better to rank with 40 DA domain redirect the domain 301 kr0smx 3 593 2019-01-02, 02:34 PM
Last Post: kr0smx







About Us | Contact Us | CPAElites | Advertise | Stats

Copyright © 2013 - 2021 by (company to be announced later)
Temporarily (!) powered by MyBB, fixed (repaired), enhanced and operated by Charlie Harper (GitHub) aka Charles Francis Harper (Wikipedia) - CPAElites - CPAElites session ranking test
Return to top
This forum uses Lukasz Tkacz MyBB addons.