{"id":4333,"date":"2020-06-01T08:05:00","date_gmt":"2020-06-01T05:05:00","guid":{"rendered":"https:\/\/trackingchef.com\/?p=4333"},"modified":"2020-12-14T15:13:41","modified_gmt":"2020-12-14T12:13:41","slug":"selective-linkedin-insight-tag-firing-based-on-location","status":"publish","type":"post","link":"https:\/\/trackingchef.com\/blog\/selective-linkedin-insight-tag-firing-based-on-location\/","title":{"rendered":"Selective LinkedIn Insight Tag firing based on location"},"content":{"rendered":"\n

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.<\/p>\n\n\n\n

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. <\/p>\n\n\n\n

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<\/a>), we figured we’d need to take a different approach to this.<\/p>\n\n\n\n

Geolocation triggers in Google Tag Manager<\/h2>\n\n\n\n

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.<\/p>\n\n\n\n

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. <\/p>\n\n\n\n

So we looked for a solution to bring the user’s location data into GTM and came across this great guide (and Template Tag!)<\/a> 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!<\/p>\n\n\n\n

Building the logic in GTM<\/h2>\n\n\n\n

First we added a new tag in GTM, using the Custom Template.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

I don’t generally recommend Custom Templates unless they’re from a trusted source, which Simo sure is.<\/p>\n\n\n\n

We named the tag with a clear name “IP Geolocation API” and pasted in the API Key. <\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

The API key can be obtained by creating a free account at https:\/\/ipgeolocation.io\/<\/a><\/strong><\/p>\n\n\n\n

Finally, we set the tag to fire on All Pages.<\/p>\n\n\n\n

Pro tip:<\/strong>
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<\/p><\/blockquote>\n\n\n\n

This tag will now load on every page and populate the Data Layer with rich location data.<\/p>\n\n\n\n

\"\"
Example location data<\/figcaption><\/figure>\n\n\n\n

This data is now available to use as triggers or blocking triggers.<\/p>\n\n\n\n

Updating the LinkedIn Insight Tag<\/h2>\n\n\n\n

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.<\/p>\n\n\n\n

So we created a new Trigger of the type Custom Event with the event name ‘geolocate’.<\/p>\n\n\n\n

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.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n

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

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

\"\"
The final tag setup<\/figcaption><\/figure>\n\n\n\n

Voil\u00e0<\/h2>\n\n\n\n

Tag is firing, data is clean, COVID-19 has been eradicated from the world (wishful thinking).<\/p>\n\n\n\n

While this implementation isn’t completely bulletproof, it does offer a basic solution to overcome LinkedIn’s lack of filters.<\/p>\n","protected":false},"excerpt":{"rendered":"

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 […]<\/p>\n","protected":false},"author":1,"featured_media":4369,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,39,41],"tags":[],"_links":{"self":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4333"}],"collection":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/comments?post=4333"}],"version-history":[{"count":6,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4333\/revisions"}],"predecessor-version":[{"id":4823,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/posts\/4333\/revisions\/4823"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/media\/4369"}],"wp:attachment":[{"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/media?parent=4333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/categories?post=4333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trackingchef.com\/wp-json\/wp\/v2\/tags?post=4333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}