Important: Valar Solutions scam - Have you been also scammed by Valar Solutions? - Please click [here] to read more! - Valar Solutions fraud
Snapchat Contest #1 Free Snapchat bot access for you! Please click [here] to read more! (Last update: 8th of January 2020)
January 2020 news -  CPAElites Essentials (2020) is coming: Please click [here] to read more!


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
  How to redirect user after completing survey with cpa build mathewocomy 1 83 2020-06-16, 02:31 AM
Last Post: DrKent
  How Redirect Locker based on ip address ? ned02 1 120 2020-05-18, 03:53 PM
Last Post: Antonio
  Looking for incentive network with geo-targeting googleman 2 369 2019-08-18, 06:58 PM
Last Post: Givenchy
  which better to rank with 40 DA domain redirect the domain 301 kr0smx 3 480 2019-01-02, 02:34 PM
Last Post: kr0smx
  can I redirect the landing page? saddies 2 507 2018-12-01, 05:58 PM
Last Post: vynilboy





About Us | Contact Us | CPAElites | Advertise | Stats

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