RankSinatra
RankSinatra

Reputation: 7

How do I create IP-based triggers on Google Tag Manager without using the Data Layer?

I need to create a trigger in GTM for all internal IPs, that I can then use as an exception trigger for another heatmap-type tag, for which I don't want to see internal activity. I know that you can add custom Javascript to push IP addresses to the Data Layer, but what I'm looking for is a trigger that just says "I'll fire if visitors' IPs are XXXX.XXXXX.XXXX." I can then use these as exception triggers. Can anyone help with this? Or if this won't work, is there any other way to filter traffic based on IPs? Please note that this needs to be done with minimal help from the devs (I'm a marketing guy with very basic Javascript knowledge).

Upvotes: 0

Views: 3369

Answers (3)

Mike Causer
Mike Causer

Reputation: 8324

GTM can't filter by IP as it does not have a Variable containing your IP.

You need to either send the users (internal/external) IP as a dataLayer variable, or fetch the users IP using javascript.

Then add a GTM Variable of type custom javascript, then use it in a GTM Trigger as a blocking rule on your Tags.

How do you get the clients IP? Have a look at this one: How to get client's IP address using javascript only?

Upvotes: 0

Saral
Saral

Reputation: 118

For filtering traffic based on IPs the easiest way would be to add IP filter in your Google Analytics View.

https://support.google.com/analytics/answer/1034823

Upvotes: 0

DanielS
DanielS

Reputation: 856

You can do this all through the Tag Manager.

In the first step you should build your own datalayer - you can fire this through the Tag Manager as Custom HTML. This coulkd be something like this:

#Get the IP-Adress
x=$.get('http://jsonip.com/', function(r){ console.log(r.ip); })
y=x.responseText
#Push the data-layer
dataLayer.push({'ip': y});

If you got this you can build a Variable in the Tag Manager to grab the Data and build a TRUE/FALSE-Logic with this DataLayer as a trigger.

Upvotes: 1

Related Questions