utag.loader.SC and utag.loader.RC

samrat_dsouza
New Member
samrat_dsouza

Hi

 

I'm placing a cookie using the utag.loader.SC("utag_mycookie", {"mycookie1": "value;exp-session"}).

It places a seperate cookie than utag_main, which is what we want.

 

However, utag.loader.RC("utag_mycookie").mycookie1, is returning undefined.

 

I have created a dataLayer as utag_mycookie, too.

 

Can someone clarify where am I going wrong?

 

We want to set two seperate cookies and read it back in an extension.

 

Thanks

Samrat D'souza

8 REPLIES 8

utag.loader.SC and utag.loader.RC

Tealium Employee

@samrat_dsouza,

 

The method you are using only works when adding cookies to the utag_main cookie. What I would recommend as a solution for you is the Persist Data Values extension in TiQ. 

 

Here is a community article that can explain more: Persist Data Value extension

 

You can persist text or an existing data layer variable and you can create multiple extensions. Then, when you need to "read" that cookie, you can do so in a set data values extension mycookie1(cp) or JS code extension utag.data['cp.mycookie1'].

 

Let me know if this doesn't work for you, or you have any other questions.

 

 

utag.loader.SC and utag.loader.RC

samrat_dsouza
New Member
samrat_dsouza

Hi @christina_schel

 

Well, wouldn't work in my scenario, as it's to be bolted into a functoinality written through an extension itself.

 

 

However, utag.loader.SC, does set a cookie but "utag.loader.RC" doesn't read it, would this be considered a bug?

 

Thanks

Sam

utag.loader.SC and utag.loader.RC

Tealium Employee

Hi @samrat_dsouza,

 

@christina_schel FYI

 

To use the 

;exp-session

You need to also include a timestamp ("_st" property) of when the session expires.

 

For example using the utag_main time out value:

 

utag.loader.SC("utag_mycookie", {"mycookie1": "value;exp-session", "_st" : utag.data["cp.utag_main__st"]});

Or if you would like to set the session timeout period from when you set the cookie you can use:

 

utag.loader.SC("utag_mycookie", {"mycookie1": "value;exp-session", "_st" : ((new Date()).getTime() + parseInt(utag.cfg.session_timeout))})

utag.cfg.session_timeout, is by default 30 mins, which can be changed via the Publish Config Setting in TiQ.

 

Adrian

Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.

utag.loader.SC and utag.loader.RC

samrat_dsouza
New Member
samrat_dsouza

Hi @adrian_browning

 

 

Thanks for the tip, however utag.loader.RC("utag_mycookie").mycookie1 doesn't work, for a similar cookie below:

Screen Shot 2016-02-18 at 13.49.31.png 

 

It does work for utag_main cookie, but for nothing other than that.

 

Should it be declare as a dataLayer, if yes then in what syntax?

 

Any tips?

 

Thanks

Sam

utag.loader.SC and utag.loader.RC

Tealium Employee

@samrat_dsouza I'm afraid your picture didn't upload.

 

To help try and explain, here is what I am doing.

(I have included some document.cookie statements to show what is in the cookie)

 

cookie_rc.png

 

 

Adrian

Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.

utag.loader.SC and utag.loader.RC

samrat_dsouza
New Member
samrat_dsouza

Hi

 

Thanks, I realised that, as I wasn't using the "_st"; utag.loader.SC worked but utag.loader.RC didn't.

 

Now, utag.loader.RC works fine.

 

Quick one before we close this thread:

Is there a exp-session setting which expires the cookie when the window is closed?

 

 

Cheers

Sam

 

 

utag.loader.SC and utag.loader.RC

samrat_dsouza
New Member
samrat_dsouza

Hi @adrian_browning

 

I'm using the solution to set and read cookies to utag_main. However, i'm facing the below issue:

 

Have a variable decarled with the cookie key name "variableName".

 

var abc = "variableName";

 

The following works in chrome, firefox and IE edge.

 

utag.loader.SC("utag_main", {[abc]: "start;exp-session"});

 

which is actually the below, but using a variable with dynamic value set, for different situations:

utag.loader.SC("utag_main", {"variableName": "start;exp-session"});

 

This, on IE 11 and lower versions, throws an error: "unexpected string".

 

Is this a bug or is there a better way to do it?

 

Thanks

Samrat D'souza

 

 

 

 

 

 

 

utag.loader.SC and utag.loader.RC

Tealium Employee

Hi @samrat_dsouza

 

So what you have come across is IE not liking defining a key name inline of an object declartaion.

 

https://kangax.github.io/compat-table/es6/#test-object_literal_extensions_computed_properties

 

Baically IE11 doesn't support ES6 Object Initializer.

 

The bit that is failing is:

 

 

{[abc]: "start;exp-session"};

 

 

The best way to do this would be to create an object first, then assign the key you want.

 

 

var abc = "variableName",
  tempObj = {};
tempObj[abc] = "start;exp-session";
utag.loader.SC("utag_main", tempObj);

 

 

 

Adrian

Ask me anything Tealium related or Javascript, or NodeJS.
Please remember to mark solutions as accepted for future searchers.