Highlighted

How do I link variables created in JSCode Extension to Sitecatalyst props/eVars?

Not applicable
I can see the variables getting set with the code I wrote in the Extension (the values can be seen with the help of alert statements) - but they are not captured in the utag object.
7 REPLIES 7
Highlighted

How do I link variables created in JSCode Extension to Sitecatalyst props/eVars?

Employee Emeritus
Hey Chaitanya, In order for mappings to work you'll need to place the variables you create in the JS Extension into the "b" namespace / object. So instead of declaring your variables like: var foo = "bar" You would do: b.foo = "bar" Then you can go into the Data Sources tab. Create a new Data Source called "foo" and leave it as the default "Data Object" type. Now you can use "foo" in the mapping section of the SiteCatalyst Tag and assign it an eVar or prop as needed. It can also be used in any other tag if needed. Hope this helps.
Highlighted

How do I link variables created in JSCode Extension to Sitecatalyst props/eVars?

Employee Emeritus
Essentially yes. :)
Highlighted

How do I link variables created in JSCode Extension to Sitecatalyst props/eVars?

Employee Emeritus
The reason the mappings aren't working in this scenario is because the js code is contained in the s_doPlugins function. The doPlugins function is designed to run after the SiteCatalyst page view function is called and Tealium will call the page view function after it has ran all it's mapping logic. So, order of operations: SiteCatalyst Tag Load Mappings are defined Extensions run (except for the doPlugins code) Mappings get assign to correct eVars / props SiteCatalyst page view function is called (s.t()) doPlugins function runs Because all the mappings have run by the time the doPlugins function has run the "b." variables aren't going to be used at this point. When adding variables to the doPlugins function, you need to assign the props / eVars directly. So in the above example you'd need to use something like: s.eVar62= s.getFullReferringDomains(); //subdomain referrer s.prop65 = s.getPreviousValue(s.pageName,'gpv_p5',''); Or you can take the code out of the function and it will run in time to be set via mappings.
Highlighted

How do I link variables created in JSCode Extension to Sitecatalyst props/eVars?

Employee Emeritus
Hey Chaitanya, It's good to point out that when you set the values directly to a prop/eVar the mappings within the Tag Config do not do anything. In this case the prop/eVar is just getting set manually. The most likely reason for the variables not getting sent on links is because linkTrackVars does not contain the prop/eVar numbers you are trying to set. linkTrackVars is set automatically for you if the mappings are being used. However, when you set the prop/eVar manually, as it sounds like you are, Tealium doesn't update linkTrackVars with those manual settings. There are a couple ways of updating linkTrackVars. Occasionally there will be a manual setting for this in the doPlugins function. If you see something like: s.linkTrackVars = "eVar##,prop##"; You can add eVar62 and 65 to this string like so: s.linkTrackVars = "eVar##,prop##,eVar62,eVar65"; Another way you can update linkTrackVars manually is by doing something like this. After your setting of the eVars like so: s.eVar62= s.getFullReferringDomains(); //subdomain referrer s.prop65 = s.getPreviousValue(s.pageName,'gpv_p5',''); Add this line: s.linkTrackVars += ",eVar65,eVar62"; Note: make sure and leave the leading comma. That is not a typo. This will append eVar65 and eVar62 to the linkTrackVars value so that it can be sent. This should allow the variables to be sent on links as well. If not, it may take a little bit of digging through your setup to really find the issue. I would suggest reaching out to your Account Manager with specifics of steps to reproduce the issue, including a URL and a link to click on, and we can dig in deeper.
Highlighted

How do I link variables created in JSCode Extension to Sitecatalyst props/eVars?

Not applicable
Jared, Thank you !! This solution worked, now utag.link() call also, these evars/ probs set through plug-in are getting passed. But, there is one catch, since we are using += in plug-in section for appending evars to s.linkTrackVars, this gets appends on every request and keeps growing with same eVar and Prop values LinkTrackVars becomes "eVar31,eVar32,eVar62,prop65,eVar62,prop65,eVar62,prop65" I'm not sure, whether we can set the s.linktrackvars to null (or '') in the plug-in section itself or using some other extension; if it can be done, in what order it should be set/ where, so that it doesn't override the linktrackvars created by Tealium on custom link calls.
Highlighted

How do I link variables created in JSCode Extension to Sitecatalyst props/eVars?

Employee Emeritus
Sorry for the delay, you can add a check to see if it has already been appended like this: if(s.linkTrackVars.indexOf("prop65")==-1){ s.linkTrackVars += ",prop65"; } if(s.linkTrackVars.indexOf("eVar62")==-1){ s.linkTrackVars += ",eVar62"; } You could also add a check to see if prop65 is defined if(s.linkTrackVars.indexOf("prop65")==-1 && typeof s.prop65!="undefined"){ s.linkTrackVars += ",prop65"; } if(s.linkTrackVars.indexOf("eVar62")==-1 && typeof s.eVar62!="undefined"){ s.linkTrackVars += ",eVar62"; } This will replace what you have already put in place and will only append prop65 or eVar62 if they are not currently appended to linkTrackVars. Hope this helps
Highlighted

How do I link variables created in JSCode Extension to Sitecatalyst props/eVars?

Not applicable
Thanks Jared !! This solution worked perfectly fine.