OceanWolf
OceanWolf

Reputation: 21

Google Analytics: How can I see the IP addresses of those visiting my site?

Using Google Analytics, what's the code I need to add to my website so I can log peoples IP addresses (v4/v6)? Is there any way to get their MACs as well? Thanks!

Upvotes: 0

Views: 1495

Answers (1)

Michele Pisani
Michele Pisani

Reputation: 14197

In Google Tag Manager navigate to Tags > New > Custom HTML and paste in the following script:

<script type="application/javascript">
  function getIP(json) {
    dataLayer.push({"event":"ipEvent","ipAddress" : json.ip});  
  }
</script>

<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"></script>

You have to create a custom dimension in Google Analytics and a DataLayer Variable called ipAddress as its value in relative field in GTM.

Note: the Google Analytics TOS does not allow to send PII to the platform, so it is at your own risk (the danger is account closure and loss of all data).

Upvotes: 1

Related Questions