Refresh JS-variable / Re-execute extension

Gold Contributor
Gold Contributor

Hi,

 

in order to get the unix time stamp and pass it upon an event is pushed into the data layer respectively to GA, I am looking for a solution to refresh a JS-variable or executing another extension which propagates into the JS-variable.

 

It's like the GTM equivalent of a variable "Hot-scoped custom dimension". As follows the code weare using:

 


function ow_time () { // Get local time as ISO string with offset at the end 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; }; utag_data.time_stamp_standard = 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); } ow_time();

 

From my understanding it similiar to timestamp_unix in Tealiums iOS Lifecycle Tracking Module. Hope anyone has an idea …

 

Many thanks & kind regards

Mike

7 REPLIES 7

Refresh JS-variable / Re-execute extension

Tealium Expert
Tealium Expert

Hi @mikeg. If I understand correctly, you want to pass the updated timestamp (ie: 2017-11-02T14:20:18.981) on every event to GA? Is that right? If so, you can map 'tealium_timestamp_local' to your GA variable. It's already calculated for you and is updated on every event, both utag.view and utag.link.

Keep in mind that the updated timestamp is in the B object on every event. It's only added to the utag.data object on the first page load event.

Good luck

Refresh JS-variable / Re-execute extension

Gold Contributor
Gold Contributor

Hi @JerTippets,

 

yes, that's what I am aiming for and thanks a lot for your suggestion. Unfortunately tealium_timestamp_local seems not to get auto updated as various events fired after each other still have the same time stamp.

 

Could it be related to the implementation on ours? We've created a JS data variable to temporarly save the time stamp. This variable is filled by an js.extension which leads me back to my original problem that the extension is executed only once.

 

Kind regrads

Mike

Refresh JS-variable / Re-execute extension

Tealium Employee

@mikeg I would have to agree with @JerTippets on this.

 

  • Visit http://www.tealiumecommerce.com/elizabeth-knit-top-601.html
  • Open the Developer Console
  • Go to the Network tab
  • Check the "Preserve log" box
  • Filter the logs on "i.gif"
  • Refresh the page
  • Grab the POST payload of the page load
  • Add the item to your cart
  • Grab the POST payload of the add to cart event

If you compare tealium_timestamp_local between the two events you'll see that they are different.

 

If it works for you here but not on your site, you should update your utag.js to the latest version.

 

Alternatively, you can add the following to a JS extension that will output the updated timestamp. This is technically what is used to output a timestamp to tealium_timestamp_local.

 

var t = {};
var d = new Date();
var m = (utag.ut.typeOf(d.toISOString) == "function");
utag.data["tealium_timestamp_local"] = (m ? d.toISOString().replace("Z", "") : "");

 

Please let me know if this helps.

 

Cheers,

-Dan

Refresh JS-variable / Re-execute extension

Gold Contributor
Gold Contributor

Hi @dan_george,

 

thanks a lot for the background knowledge. Unfortunately the time stamp is not calculated upon each event is send or an extension is executed so we can pass the time stamp as a cusotm dimension. The time stamp variable seems a bit static or do I miss a vital part?

 

Thanks

Mike

Refresh JS-variable / Re-execute extension

Tealium Employee

@mikeg I'd be interested to know which version of utag you are running and start there.

 

If there is a URL where I can see this, as well as steps to trace, I'd be interested in knowing. Otherwise, unfortunately this might require a support ticket to research why this is occurring.

 

Hoping for some good news...

-Dan

Refresh JS-variable / Re-execute extension

Gold Contributor
Gold Contributor

@dan_george, one website is seton.co.uk

 

Edit: Our Tealium agency updated to the most recent version and said we should now be able to use tealium_timestamp_local … thanks a lot for your support Dan!

Refresh JS-variable / Re-execute extension

Tealium Employee

@mikeg

 

Good to hear! I was just testing this morning and can see the tealium_timestamp_local working as expected on a product page.

 

Cheers,

-Dan

Public