This article describes how to incorporate geolocation API services into Tealium iQ.

This article covers the following topics:

Geolocation Services 

With real-time geolocation services, you can locate and identify website visitors via their IP address. Here is a list of several geolocation services:

Please note: These are third-party vendors and not affiliated with Tealium in any way. Setting up and configuring any third-party geolocation service is the sole responsibility of the client.

How It Works

We are using the Tealium Generic Tag to load the geolocation service, a custom JavaScript code extension to parse the geolocation results, and new data layer variables to store the geolocation data and use it in the Tealium iQ configuration.

In this example, using ipstack, the geolocation results are parsed in a callback function. This function will be defined in a JavaScript Code extension and the name of the function will be passed to ipstack as a querystring parameter. The ipstack tag knows to call this function automatically.

Each geolocation service might use a different mechanism for triggering the callback.

Once the geolocation is parsed there are a couple options for how to proceed. You could make a tracking call (presumably to pass data to AudienceStream to update visitor records) or save the data in localStorage for use client-side.

Tealium Generic Tag

In Tealium iQ, create a Tealium Generic Tag with the following configuration settings (leaving other settings as default values)

  • Title: GeoLocation Service
  • Type: Script
  • Base URL
  • QueryStringaccess_key=ACCESSKEY&callback=utag.ut.parse_geo

JavaScript Code Extension

Add a JavaScript code extension to define the callback function utag.ut.parse_geo . The following example determines the customer's location information.
var geo={};
.ut.parse_geo = function(data) {
if (data && typeof data == "object" && data != {}) {
  geo.geo_city = ( ? : "N/A";
   geo.geo_state = (data.region_code) ? data.region_code : "N/A";
   geo.geo_country_code = (data.country_code) ? data.country_code : "N/A";
   geo.geo_location = geo.geo_city + ", " + geo.geo_state;
// make a tracking call or just save the data to localStorage;

Data Layer Variables

Create any variables that you may need in the Data Layer tab, such as:

  •  geo_city: geolocation city
  •  geo_state: geolocation state
  •  geo_country_code: geolocation country code
  •  geo_location: combination of geolocation city and state

Click Save/Publish when you have completed setting up your GeoLocation custom tag.


For a use case of using geolocation services, check out Advertising Against Weather Forecast to target website visitors based on their weather forecast.  The video shows how to combine the geolocation service tag with ad targeting using AudienceStream.

Version history
Last update:
‎10-16-2020 02:06 PM
Updated by: