Highlighted

Our mobile website requests permission to use location services, and if enabled customizes the experience for phone's location. How do I pull that information into the Tealium data layer so that I can make it available to my analytics tags?

Bronze Contributor
Bronze Contributor
Mobile web location information
3 REPLIES 3
Highlighted

Our mobile website requests permission to use location services, and if enabled customizes the experience for phone's location. How do I pull that information into the Tealium data layer so that I can make it available to my analytics tags?

Tealium Employee
Hi Wayne, I'm not the most familiar with how the location services works, but I'm assuming there is something that is set on the OS level that tells the browser it can use the service. That setting needs to make it's way into the browser DOM. Once there, we can easily pick up the value. Do you know if there is a service check the browser makes and if so if the result can be brought into the browser?

Our mobile website requests permission to use location services, and if enabled customizes the experience for phone's location. How do I pull that information into the Tealium data layer so that I can make it available to my analytics tags?

Employee Emeritus
You would need to set variables via the navigator.geolocation.getCurrentPositon() in a callback like var lat = 0; var long = 0; navigator.geolocation.getCurrentPosition(function(position){ lat = position.coords.latitude; long = position.coords.longitude; },function(error){ //use error.code to determine what went wrong }); because this is an async call its best to do something like navigator.geolocation.getCurrentPosition(function(position){ utag.data.lat = position.coords.latitude; utag.data.lon = position.coords.longitude; utag.view(utag.data); // or utag.view({lat:position.coords.latitude,long:position.coords.longitude}); },function(error){ //use error.code to determine what went wrong }); something like that should accomplish what you need.
Highlighted

Our mobile website requests permission to use location services, and if enabled customizes the experience for phone's location. How do I pull that information into the Tealium data layer so that I can make it available to my analytics tags?

Employee Emeritus
It's part of the HTML5 spec, and it always requires the visitor permission to run. That's why Patrick's example showed running utag.view() after the user grants permission. It's kind of complicated in relationship to tagging. Factors include: 1. Do I double on calls then since I already fired a pageview on initial load? 2. If I don't double on calls, what do I do if they ignore the location permission prompt?