CMS Development

Kirsten8686
Participant

How to detect IP country to show relevant Menu

SOLVE

Hello! We've recently built two menus on our HubSpot CMS - one for the UK and one for US. 

How do I get it to detect the IP country so that the right menu is shown for that visitor?

0 Upvotes
1 Accepted solution
piersg
Solution
Key Advisor

How to detect IP country to show relevant Menu

SOLVE

Something to be aware of when using request.headers is that it disables page caching which could negatively impact your website/page performance.

 

If you're using a global module, you could do what @Kevin-C suggested and use smart content in that module to display different content based on different locations.

View solution in original post

0 Upvotes
3 Replies 3
BarryGrennan
Top Contributor

How to detect IP country to show relevant Menu

SOLVE

You can get ip country using

{{request.headers|attr('cf-ipcountry')}}

profile2022aBarry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn

 

 

piersg
Solution
Key Advisor

How to detect IP country to show relevant Menu

SOLVE

Something to be aware of when using request.headers is that it disables page caching which could negatively impact your website/page performance.

 

If you're using a global module, you could do what @Kevin-C suggested and use smart content in that module to display different content based on different locations.

0 Upvotes
Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

How to detect IP country to show relevant Menu

SOLVE

Hey @Kirsten8686 

 

I have not done it before but i believe this can be done by enabling the custom content option in a module.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
0 Upvotes