- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
09-18-2020 04:17 PM - edited 09-18-2020 04:18 PM
Hi, I need to use a custom timestamp like 2020-09-18T17:56:53.679-05:00 With the time zone.
I created a UDO variable
_timestamp (UDO)
And added a javascript extension
// Type your JavaScript code here...
b._timestamp = (function() { var now = new Date(); var tzo = -now.getTimezoneOffset(); var dif = tzo >= 0 ? '+' : '-'; var pad = function(num) { var norm = Math.abs(Math.floor(num)); return (norm < 10 ? '0' : '') + norm; }; return now.getFullYear() + '-' + pad(now.getMonth()+1) + '-' + pad(now.getDate()) + 'T' + pad(now.getHours()) + ':' + pad(now.getMinutes()) + ':' + pad(now.getSeconds()) + '.' + pad(now.getMilliseconds()) + dif + pad(tzo / 60) + ':' + pad(tzo % 60); }());
Linked to Google Analytics mapped variables _timestamp to a custom dimension.
But the _timestamp keeps the initial value,
I tried to use tealium_timestamp_local or tealium_timestamp_utc but we need the timezone, I need a way to create a similar function that is triggered when any GA action is fired.
Thank you!
Solved! Go to Solution.
09-21-2020 01:58 AM - edited 09-21-2020 03:03 AM
Not sure why this is not working for you.
I tried to replicate but get expected result, here is what i did:
I setup a BLR extention with your code:
Mapped the _timestamp to a CD for all page hits
I have a document click handler set to generate a GA event for testing. As you see below each hit generated a new timestamp.
Hope this helps.
Not sure if it is related, but if it is still not working for you. try create a new data layer var, and using the set data extention, set it to the _timestamp and publish.
If it gets it working, then remove the set var extention and it should continue working (i don't know the why, but when i get the odd gremlin like this, sometimes it gets things working....)
Gavin
I checked run once... that's why it didn't work, was my fault, thank you!!!
Copyright All Rights Reserved © 2008-2023