Recently I’ve helped a friend set up a Google Tag Manager (GTM) container for a project he’s working on. As in many cases the GTM container held many tag, including the LinkedIn Insight Tag.

My friend thought that it would be nice to analyze the Website Demographics report from the Insight Tag’s data, to expose which companies have visited the project’s page.

But to his disappointment, he discovered out that their internal traffic was “messing up” LinkedIn’s data, and could extract little insight from it. Since LinkedIn doesn’t offer many options to filter internal traffic (unlike tools like Google Analytics), we figured we’d need to take a different approach to this.

Geolocation triggers in Google Tag Manager

With COVID-19 still at its peak, and everyone working from home, IP filtering wasn’t option. In any case this isn’t a stable solution in GTM though some methods do exist.

The other way we thought we can approach this was through the user’s location. We knew that traffic outside of Israel (where the company’s HQ is located) definitely prospects, with Israeli companies being a secondary targeting for their marketing.

So we looked for a solution to bring the user’s location data into GTM and came across this great guide (and Template Tag!) by Simo Ahava. In a nutshell, Simo created a Template Tag for GTM that connects to an API that parses the user’s IP to their exact location. Oh, and it’s free (up to 30k request monthly). Eureka!

Building the logic in GTM

First we added a new tag in GTM, using the Custom Template.

I don’t generally recommend Custom Templates unless they’re from a trusted source, which Simo sure is.

We named the tag with a clear name “IP Geolocation API” and pasted in the API Key.

The API key can be obtained by creating a free account at

Finally, we set the tag to fire on All Pages.

Pro tip:
Since the API is limited to 30k requests per month, you can save the location data in the session storage to reduce requests on sequential pages

This tag will now load on every page and populate the Data Layer with rich location data.

Example location data

This data is now available to use as triggers or blocking triggers.

Updating the LinkedIn Insight Tag

Now that the data is available, we set to change the Insight Tag. First, we created a new Trigger, so that the tag won’t load on ‘All Pages’. Since the Geolocation Tag loads on all pages at a relatively early stage, we figured we can use its response to load the Insight Tag without losing data.

So we created a new Trigger of the type Custom Event with the event name ‘geolocate’.

We then added a firing rule to restrict the tag only to fire if a certain Data Layer Variable (DLV) isn’t equal to the geo we wanted to exclude.

In this case we wanted to exclude Israel, so created a DLV to capture the country’s name “geoData.country_name”.

Similarly, you can exclude a specific city with “”, for example if your HQ sit in Liverpool but you don’t want to exclude of of the United Kingdom.

The final tag setup


Tag is firing, data is clean, COVID-19 has been eradicated from the world (wishful thinking).

While this implementation isn’t completely bulletproof, it does offer a basic solution to overcome LinkedIn’s lack of filters.

About the Author

Elad Levy

Experienced Web Analyst, working for almost a decade now with various web analytics tools.
Also a husband, father of two rascals, and the co-founder of Fixel.

Leave a Reply