Geo-IP onClick redirect
2016-03-14, 03:50 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, 03:59 AM,
#2
Latest Thanks - View all

ςσsmiη(2016-03-14 02:51 PM) 
Reply
2016-03-14, 10:34 AM,
#3
Link Cloaker WordPress plugin does this for you.

CPA Elites ONLY $10 OFF Discount for Gram Poster: Schedule Instagram Posts.
Reply
2016-05-04, 01:14 AM,
#4
It worked ?

/20 charact
Reply
2016-05-05, 08:30 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
Latest Thanks - View all

ςσsmiη(2016-05-05 02:40 PM) 
Reply
2016-05-05, 02:40 PM,
#6
(2016-05-04, 01:14 AM)Wolfz Wrote: It worked ?

/20 charact

Nope, answer is below:

(2016-05-05, 08:30 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, 08:01 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>'
Latest Thanks - View all

ςσsmiη(2016-05-06 03:02 PM) 
Reply
2016-05-10, 04:01 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, 06:09 PM,
#9
or you can try this link shortener for country redirect. they also have mobile redirect too.
https://manage.smarturl.it/
Latest Thanks - View all

ςσsmiη(2016-05-28 09:57 PM) Khaleesi(2016-05-10 06:45 PM) 
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Landing Page [redirect] buzzshares 9 264 2017-10-02, 05:21 AM
Last Post: buzzshares
  [Question] Could a GEOIP Redirect be a reason for dangerous browser warnings? CheDz 1 93 2017-09-20, 03:42 PM
Last Post: zamnajali
  OGads captcha locker onclick code ? gamertrial1 1 166 2017-08-11, 10:04 AM
Last Post: lovecash
  Redirect on the Basis of Age? Qoins 1 130 2017-07-26, 06:18 PM
Last Post: YalaYolo
  Need Help With ONCLICK Contenlocker and WordPress 5light 7 260 2017-06-27, 08:41 PM
Last Post: 5light




About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top