Home > Programming, Servers & Scripts >

Is there a way to show a lander if user is from a specific country? (8)


12-21-2015 07:27 AM #1 alfiss (Member)
Is there a way to show a lander if user is from a specific country?

Without using a tracker, and doing it directly on an index.php file.

For example www.page.com/lander/index.php.

If the user types that, if the user is from US, it shows page A (while staying on index.php). And if user is from UK, it shows page B (while staying on index.php)

Any clue on how that can be done?


12-21-2015 09:21 AM #2 matuloo (Legendary Moderator)

Its doable but it requires some custom coding. I have a lander like this, it uses two way verification.

1st step - I have maxmind GEO extension installed on the server, so the php code asks for the GEO and can serve localized LP.
2nd step - Script checks language setting of the browser and can serve translated LP based on that.

Any coder should be able to make this for you.


12-21-2015 10:42 AM #3 zenka1992 (AMC Alumnus)

EDIT: Okay, just now noticed, that the user needs to stay in the index.php file... So I believe this won't work for you lol.

I have such script. Used sometime ago http://www11.zippyshare.com/v/n8oJJwZg/file.html , just edit the gredirect.php file with notepad and send users to it (you can rename it of course as index.php).

Here's an example:
if($country_code == 'CA')
{
header('Location: http://www.google.com');

In this case Canadian visitors will be sent to google. Same goes to any others countries, you can add them yourself and delete uneeded ones. The last one, which is "else" without a country, is a website where all visitors not from particular mentioned above country will be sent. I'm sure you'll get the hang of it. Be sure to test it before running.


12-21-2015 11:57 AM #4 TheComedian (Member)

if you use a tracking tool with that capability, such as Voluum for example, you should be able to do it without any need of coding.


12-22-2015 04:02 AM #5 alfiss (Member)

Thanks for help guys.


htt

Quote Originally Posted by zenka1992 View Post
EDIT: Okay, just now noticed, that the user needs to stay in the index.php file... So I believe this won't work for you lol.

I have such script. Used sometime ago http://www11.zippyshare.com/v/n8oJJwZg/file.html , just edit the gredirect.php file with notepad and send users to it (you can rename it of course as index.php).

Here's an example:
if($country_code == 'CA')
{
header('Location: http://www.google.com');

In this case Canadian visitors will be sent to google. Same goes to any others countries, you can add them yourself and delete uneeded ones. The last one, which is "else" without a country, is a website where all visitors not from particular mentioned above country will be sent. I'm sure you'll get the hang of it. Be sure to test it before running.
Looks good, but the user needs to stay on the index.php though.

I basically found a lander, and opening it up on my browser shows me variation A. When I pop into a proxy it shows me variation B. (All the time without changing the URL).

Intrigued the fuk out of me, and could see so many uses to this. Great if anyone has a clue


12-22-2015 11:11 AM #6 caurmen (Administrator)

matuloo's solution is the one you want. That'll work reliably.

Essentially, rather than using the header(blah) approach zenka suggests, you'd have the location detection PHP in the first lines of the lander, then have two landers ready in the same directory, called, say, geo.php and outofgeo.php.

Then if the user is in the geo you want to target, you just use the line

include "geo.php";

and that'll write the contents of that php file to the lander that the user sees. So the user will see index.php but the content will be from the file you called geo.php.

Interestingly, you can also do this without using a server-side language at all. Nginx and Apache(I think) can both do exactly this kind of content substutition based on internal scripting. But that's getting a little bit into system administration black magic - although it's very useful if you want to run this kind of thing at huge scale.


12-22-2015 12:11 PM #7 alfiss (Member)

Quote Originally Posted by caurmen View Post
matuloo's solution is the one you want. That'll work reliably.

Essentially, rather than using the header(blah) approach zenka suggests, you'd have the location detection PHP in the first lines of the lander, then have two landers ready in the same directory, called, say, geo.php and outofgeo.php.

Then if the user is in the geo you want to target, you just use the line

include "geo.php";

and that'll write the contents of that php file to the lander that the user sees. So the user will see index.php but the content will be from the file you called geo.php.

Interestingly, you can also do this without using a server-side language at all. Nginx and Apache(I think) can both do exactly this kind of content substutition based on internal scripting. But that's getting a little bit into system administration black magic - although it's very useful if you want to run this kind of thing at huge scale.

Thanks Caurmen, totally missed out matuloo's post!

I was looking at zenka's code and tried it out, it worked but just that it redirects the user to XXX URL instead.

But seeing how maxmind geo basically does the same thing where it locates the user's location, is there a reason why I should I pay $24/month for maxmind geo? Or it wouldn't be possible to use zenka's method to show geo.php or outofgeo.php on the actual index.php file?


12-28-2015 06:46 PM #8 twinaxe (Senior Moderator)

I use something like that.
If you need help with the PHP send me your skype.
I will guide you through it then.


Home > Programming, Servers & Scripts >