Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

GeoTargeting

GeoTargeting

Hello!
I just bought Chameleon but I dont know how to do this GeoTargeting:

I need to show 2 different hompages depending on the region the visitor comes from:
- Homepage A for 4 big cities
- Homepage B for the rest

Can you help me?
Thanks!
Juan

juan123de
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: GeoTargeting

Hi,

1 - use the Chameleon Configuration page (not rule page) to download a copy of the free GeoLite City database

2 - create your 2 different home pages. Suggestion: Put your "default" home page as the 1st menu item in the main menu, and the special home page (for the 4 big cities) as the 2nd menu item in the main menu. Don't worry, we'll set it up so each visitor only sees one of them.

3 - create a new Chameleon rule and name it

4 - in the "Config" tab of the rule, select "Enable GeoIP/GeoCity": GeoLiteCity (Free).

5 - in the PHP panel in the Chameleon rule, enter the following:

Code:

$city = strtolower($geoip->city);

$country = $geoip->country;
if ($country != 'Spain') return false; // ignore the rest of the rule if visitor NOT in Spain - make the rule FAIL
// alter the list of cities here to suit your needs:
if ($city == 'barcelona' or $city == 'madrid' or $city == 'malaga' or $city == 'granada') return true; // make the rule SUCCEED
return false; // i.e. they were in Spain but not one of the main cities - make the rule FAIL

6 - we'll use the SUCCEED action (i.e. visitor was in one of the 4 cities) to change the default menu item, and HIDE the other menu item:

- in the Actions tab in the Chameleon rule, in the SUCCEED Actions column, use the "Site Default Menu Item" dropdown to select the alternative home page.
- also in the Succeed Actions column, in the Unpublish Menus box, select the main default home page. This will remove that menu item from display, so visitors only see the alternative one.

7 - we'll use the FAIL action to simply hide the alternative home page item because it's unnecessary

- in the FAIL Actions, in the Unpublish Menus box, select the "alternative" home page menu item. This will remove that menu item from display, so visitors only see the standard one.

8 - save the rule and test.

Please note: the GeoLiteCity database from MaxMind is not particularly accurate in detecting cities, depending on what country you are in. You will find that for a significant proportion of your visitors, it will get it wrong, and there's nothing Chameleon can do about that. See https://www.maxmind.com/en/geoip2-city- … olution=50 for some info on accuracy in Spain.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: GeoTargeting

Hi Stephen!

Thank you for your fantastic explication! The problem is that it always fails :-)

Is there any way to use regions instead? Maybe this works better!  I need to show one offer only in two regions (Canary Islands and Balearic islands...). The restshould fail! Or any way to get a cheap more acurate database?

best regards!

juan123de
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: GeoTargeting

Hello! I solved it modding your script!

Best result I get with region codes:


$region = strtolower($geoip->region);
if ($region == '07' or $region == '08') {return true;
} else {
return false;}

Thanks a lot!!!

juan123de
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: GeoTargeting

Better:

$country = $geoip->country_code;
$region = strtolower($geoip->region);
if ($country != 'ES') return false;
if ($region == '07' or $region == '08') {return true;
} else {
return false;} // i.e. they were in Spain but not one of the main cities - make the rule FAIL

juan123de
Beginner Modder
ranks
useravatar
Offline
4 Posts
Administrator has disabled public posting

Re: GeoTargeting

That looks great Juan - looks like the region codes are going to be more accurate than the cities, too.
Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Posts this week:
1
User Info:
 
Total Users:
10119
Newest User:
watytb5
Members Online:
3
Guests Online:
195


Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked