# get user geolocation

**URL:** <https://community.hubspot.com/t/get-user-geolocation/52839>\
**Category:** CMS Development\
**Created:** [March 9, 2022, 6:34pm UTC](https://community.hubspot.com/t/get-user-geolocation/52839 "2022-03-09T18:34:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![llopez1](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@llopez1](https://community.hubspot.com/u/llopez1)\
**Post date:** [March 9, 2022, 6:34pm UTC](https://community.hubspot.com/t/get-user-geolocation/52839/1 "2022-03-09T18:34:49Z")

</div>

Hello community, I would like to display my content sorted according to the visitor’s country. I have been doing some research and I could use the ip of the user and work with a third party service like ‘ipstack’ to get the country but I wonder if there is a free way to do it just with hubspot?

the content I want to display is displayed by a module and consumed from hubdb.

---

<div class="post-metadata">

**Author:** ![miljkovicmisa](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miljkovicmisa/32/86357_2.png) [@miljkovicmisa](https://community.hubspot.com/u/miljkovicmisa)\
**Post date:** [March 10, 2022, 10:24am UTC](https://community.hubspot.com/t/get-user-geolocation/52839/2 "2022-03-10T10:24:37Z")

</div>

Hello @llopez1 , HubSpot does some geolocation out of the box, in the docs you can find the [HTTP Request Vriables](https://developers.hubspot.com/docs/cms/hubl/variables#http-request-variables) that documents all kinds of variables that are tied to the request, thus you can use either the {{ request.geoip\_country }} or the documented {{ request.headers.cf-ipcountry }} to check on the Country Code that came with the IP.  
If you need further help don’t hesitate to write here.  
Cheers!  
_ **If my answer was helpful please mark it as a solution.** _

---

<div class="post-metadata">

**Author:** ![lstepany](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lstepany/32/54675_2.png) [@lstepany](https://community.hubspot.com/u/lstepany)\
**Post date:** [September 25, 2024, 9:15am UTC](https://community.hubspot.com/t/get-user-geolocation/52839/3 "2024-09-25T09:15:25Z")

</div>

{{ request.country }} this worked for my

---

<div class="post-metadata">

**Author:** ![mangelet](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mangelet/32/83031_2.png) [@mangelet](https://community.hubspot.com/u/mangelet)\
**Post date:** [March 10, 2022, 1:08pm UTC](https://community.hubspot.com/t/get-user-geolocation/52839/4 "2022-03-10T13:08:20Z")

</div>

@llopez1

**1) Smart content modules** display different versions of your content based on viewer category.

You can base your smart rules on the country. The country is determined by the IP address of the visitor.

**2) On a Contact record there is a field ‘IP Country’**, which automatically fills in a Country.

Consider using `{{contact.ip_country}}` in your templates. Then add conditional logic as you please.

---

<div class="post-metadata">

**Author:** ![Kvis1](https://avatars.discourse-cdn.com/v4/letter/k/e9a140/32.png) [@Kvis1](https://community.hubspot.com/u/Kvis1)\
**Post date:** [May 14, 2024, 7:01pm UTC](https://community.hubspot.com/t/get-user-geolocation/52839/5 "2024-05-14T19:01:38Z")

</div>

I do not see these variables. Is this another outdated solution?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [May 16, 2024, 8:59pm UTC](https://community.hubspot.com/t/get-user-geolocation/52839/6 "2024-05-16T20:59:50Z")

</div>

Hey, @Kvis1. Thanks for your comment. It looks like the available variables have been updated, and no longer include the two mentioned by @miljkovicmisa. I’m going to add this to my archive list since it is outdated.

You are welcome to create a new post if you still need help, and we’ll do our best to get some of our community experts to take a look.

Best,

Jaycee
