Attention: Server migration delayed. - Please click [here] to read more! (Last update: Sunday, 21st of April, 08:45 PM/20:45, UTC+2, Europe)


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
Share This Thread :

2016-03-14, 03:59 AM,
#2
Reply
2016-03-14, 10:34 AM,
#3
Link Cloaker WordPress plugin does this for you.

Boost Your Instagram Likes: Boosted Likes
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
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>'
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/
Reply


Related Threads
Thread Author Replies Views Last Post
  which better to rank with 40 DA domain redirect the domain 301 kr0smx 3 271 2019-01-02, 06:04 PM
Last Post: kr0smx
  Looking for incentive network with geo-targeting googleman 1 135 2019-01-02, 05:38 AM
Last Post: naruto87
  can I redirect the landing page? saddies 2 319 2018-12-01, 09:28 PM
Last Post: vynilboy
  GEO Redirection Script immart247 7 473 2018-10-31, 12:40 PM
Last Post: JenniN
  onclick cpagrip help pokefan59 9 525 2018-10-19, 06:33 AM
Last Post: Kjartansson





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

Copyright © 2013 - 2019 by (company to be announced later)
Enhanced by MyBB
Return to top
This forum uses Lukasz Tkacz MyBB addons.