Hi @mitchellt,
I saw on another post you were still interested in this capability and I know we've solved this for other customers already using the response headers from our CDN endpoint.
The TiQ CDN has a location service we can hit at https://akamai.tiqcdn.com/location/location.js.
Using the response headers, you should be able to output the desired data layer variables you need for location based consent (or any other creative purpose you can think of).
Here is an extension that was developed by our Technical Trainer here in Melbourne, Aus (I'm not taking credit for this - Thanks Zac). Feel free to customise based on your needs.
// Grab script (async)
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://akamai.tiqcdn.com/location/location.js', true);
// If successful, grab the x-edgescape-location header, create a hash table and build UDO variables
xhr.onload = function (e) {
if ((xhr.readyState === 4) && (xhr.status === 200)) {
var edgescape = {};
var str = xhr.getResponseHeader('x-edgescape-location');
var pieces = str.split(','), part;
for (var i = 0; i < pieces.length; i++) {
part = pieces[i].split('=');
edgescape[part[0]] = part[1];
}
utag_data.current_city = edgescape.city;
utag_data.current_region_code = edgescape.region_code;
utag_data.current_country_code = edgescape.country_code;
} else {
console.error(xhr.statusText);
}
};
// Fail semi-gracefully
xhr.onerror = function (e) {
console.error(xhr.statusText);
};
// Do magic
xhr.send(null);
This will output the relevant data layer variables you need. Use the CSV import for your Tealium iQ profile and paste the following.
current_city,UDO Variable,Current City,Populated from the TiQ CDN location service
current_region_code,UDO Variable,Current Region Code,Populated from the TiQ CDN location service
current_country_code,UDO Variable,Current Country Code,Populated from the TiQ CDN location service
Would love to hear how you go with this, please keep us posted.
Good luck
Kieran
... View more