/***
* This transformation enriches events with geolocation data using an IP-to-geolocation API powered by Maxmind, available from https://www.maxmind.com.
* This allows you to easily query events based on geolocation data, e.g., country, city.
***/exportasyncfunctiontransformEvent(event,metadata){if(event.request_ip){try{if(!event.context)event.context={};event.context.geo=awaitgeolocation(event.request_ip);}catch(e){log(e.message);}}returnevent;}
In the above transformation, the geolocation service function (geolocation) takes the IP address present in the event (request_ip) as an argument. Once it runs successfully, it returns the following geolocation data:
City
Country
Region
Location
Postal code
Timezone
Note that:
The geolocation data provided by RudderStack powered by Maxmind is not 100% accurate and varies by country. See the Maxmind website (link: https://www.maxmind.com/en/geoip2-city-accuracy-comparison) to get the accuracy information by country.
RudderStack returns a 400 Bad Request error if you pass a malformed IP address.
If you currently use a geolocation enrichment template, switching to this transformation will result in some schema changes:
RudderStack creates new columns for the IP addresses in your warehouse.
It stores the country code instead of country name.
FAQ
How is this feature different from the geolocation enrichment transformation template?
RudderStack’s geolocation service feature lets you enrich events with users’ geolocation information for a given IP address by leveraging the licensed GeoLite2 data created by MaxMind.
On the other hand, the geolocation enrichment template enriches events with geolocation data using an IP-to-geolocation API endpoint that you need to provide.
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.