Highlighted

how can we capture the ip address on a variable in tealium?

Rookie Contributor

Hi there, 

We would like to capture the IP Address of our customer and send that information on GA as a customer dimension. How can we collect that data on a variable?

 

Many thanks 

2 REPLIES 2
Highlighted

how can we capture the ip address on a variable in tealium?

Tealium Employee

Hi @cristinaBmind ,

This would be one possible approach, using any API provider on the market. There are quite a few options, some free, some with limitations specially the free ones, some other payed ones.
See this list of examples:
https://stackoverflow.com/questions/391979/how-to-get-clients-ip-address-using-javascript


Once you decided with which vendor to go, here is a list of steps:

  • add a dom ready javascript extension
    • add the vendor code snippet to fetch the ip
    • on the vendor callback, make a utag.link() call with the data returned.

EX:

utag.link({
    event_name : "client_ip",
    ip_address : {{data with ip returned from the vendor call}}
})

with this in place, we can then catch the "client_ip" event and send it to any vendor, in your case GA.

  • create a new datalayer variable called ip_address
  • map it in the tag mapped variables (ex. bellow ip_address goes to CD10)

2020-01-10_14-41-20.png

Highlighted

how can we capture the ip address on a variable in tealium?

Rookie Contributor
const Http = new XMLHttpRequest();
const url9="https://api.ipify.org/?format=text";
Http.open("GET", url9)
Http.send();

Http.onreadystatechange = (e) => {
  console.log(Http.responseText)
  console.log("ipify call sucesesful")
  
  var ip_address_ipify = (Http.responseText)
  utag_data.ip_address_ipify=ip_address_ipify;
}

Barry Mann