Track IP Address in Google Analytics using GTM

In response to many questions about tracking IP addresses in Google Analytics, this is a follow-up post to Get Visitor IP Address with Google Tag Manager. Please follow the instructions in that post first to collect visitor IP address into a GTM Variable and create a GTM event. Once those steps are complete, you can follow these remaining steps in this post to pass the IP address to GA.

It’s a grey area whether IP addresses are considered personal information. Please be aware of your site’s privacy policy, any relevant local laws, and Google’s policies regarding personally identifiable information. The new GDPR rules DO consider IP addresses to be personal data, as described here: https://eugdprcompliant.com/personal-data/.

NEW! API CONNECTOR ADD-ON FOR GOOGLE SHEETS

Check out my new API Connector Add-on to import data from thousands of platforms (e.g. Shopify, Harvest, Mailchimp, ActiveCampaign, VWO, YouTube, etc.) directly into Google Sheets.

STEP 1: SET UP A SESSION-SCOPED CUSTOM DIMENSION IN GA

In the Google Analytics interface, navigate to Admin > Property > Custom Definitions > Custom Dimensions

ip-address-ga-img1

Click + NEW CUSTOM DIMENSION and create a new session-scoped custom dimension called IP Address. Save it.

ip-address-ga-img2

STEP 2: RECORD THE INDEX NUMBER

After hitting Save, you’ll see your custom dimension summary screen. Note the index number that was assigned by Google Analytics. You’ll need this in a minute.

ip-address-ga-img3

STEP 3: CREATE A UNIVERSAL ANALYTICS EVENT TAG

In Google Tag Manager, click Tags > New > Universal Analytics, and choose Track Type = Event. Fill it out with the following settings:

Category = IP, Action = Sent. These names aren’t important, so you can choose different names if you prefer.
Non-Interaction Hit = True. This is to prevent the hit from affecting bounce rate.
Enable overriding settings in this tag  = checked (or, alternately, you can add the index and dimension value into your Google Analytics Settings Variable instead).
Index = index number from step 2 above
Dimension Value = {{IP Address}} . The IP Address variable should have already been implemented via the instructions in  Get Visitor IP Address with Google Tag Manager.
Trigger = ipEvent. This ipEvent trigger should also already have been implemented via the instructions in Get Visitor IP Address with Google Tag Manager.

The completed tag should look like this:

ip-address-ga-img4

CONCLUSION

The first post showed how to collect a user’s IP address into a GTM Variable. This post extends that to show how to pass that IP address into a custom dimension in Google Analytics. Because custom dimensions need to be attached to another hit like a pageview or event, the above method sends the IP address along with a dummy event. Once you complete the above directions, you will be able to access your users’ IP addresses as a Secondary Dimension in any standard report, or as a Primary Dimension in a custom report. You can also use these custom dimensions to target specific audiences for remarketing.

 

GOOGLE TAG MANAGER CONSULTING

Get your own tag manager! Click for information on my Google Tag Manager consulting service.

Comments:9

    1. I can’t say for sure without access to your GTM account. But when I tested my own container on your site, it worked but fired the event tag hundreds of times instead of just once. Based on that, I think you have a misconfiguration of the custom HTML tag. If you’d like me to be more specific, please give GTM access to info@ mixedanalytics.com so I can log in and check it.

  1. I’d love to see from your perspective if I set mine up correctly… IP tracking is new to me and I tried to follow step by step – not sure what the results are supposed to look like.

    1. To check the results, you can open any report — for example, the Devices report located at Audience > Mobile > Overview. From here, open the Secondary Dimension dropdown menu and choose IP Address to see your new custom dimension. If all is working, you should see a list of IP addresses next to each device type.

      1. If you see it in GTM preview mode, then it means you’re getting the IP address back from the service (in other words, your ‘IP Detect’ tag is fine).
        Since you have IP address in GTM, it’s just like setting up any other custom dimension in GA. You need to a) attach the variable to a tag in GTM and b) set up a custom dimension in GA to receive it. Can you please clarify that your IP Address variable is named {{ipAddress}} and you’ve enabled custom dimension 1 in GA?
        Also, how are you testing this? If it’s just your own traffic, you probably won’t fire the landing page tag since you’ve already been clicking around the site, so make sure you’re testing in a new browser or incognito mode.

      2. yes . Ip Address variable is ipAddress , index is 1 and i enabled in GA . I tested by checking visit of customers. Now i know i set up correctly , maybe it takes more time to appeared . Thank you Ana

Leave a Reply

Your email address will not be published.