Take part of querystring variable and save it as a variable

SKammerlocher
Visitor
SKammerlocher

Hi guys, 

We use a querystring parameter for our campaign parameters which looks like xcmp=source_medium_additionalInformation

This xcmp parameter is already saved as a Querystring-Parameter in Tealium iQ. But now I would like to take only the last part of this variable (in this case additionalInformation) and save this in a new variable "last_part" to be able to send only this information to Google Analytics. 

I tried a Javascript-Extension: 

var xcmp = utag.data["qp.xcmp"].split('_');
var last_part = xcmp[xcmp.length-1];
if (xcmp.length >= 1){
utag.link({
"last_part" : last_part
});
}

 

as soon as I enter utag.link to this Javascript Extension my page isn't loaded and Tealium drives crazy. 

Can you please help me to solve this problem?
Thanks,

Sophie

 

 

2 REPLIES 2

Take part of querystring variable and save it as a variable

UnknownJ
Occasional Contributor
UnknownJ Occasional Contributor

Hi @SKammerlocher,

The problem you're experiencing is that the utag.link function initiates Tealium's event processing, but if you've got an extension that uses it, you'll generally end up in an infinite loop.

In the case below, you'll want the code to read:

var xcmp = b["qp.xcmp"].split('_');
if (xcmp.length >= 1){
  b.last_part = xcmp[xcmp.length-1];
}

The first change is to replace the reference to utag.data to a reference to the variable, which in an event-scoped extension (Before Load Rules, After Load Rules or Tag-Scoped) will contain the current state of the UDO. The second change then is to use this reference to the UDO to write the last element of the array to the last_part variable in the UDO, which will make it available to subsequent extensions, and to tags (provided you've created the last_part variable within Tealium IQ's UDO).

Hope that helps, give me a shout if you need any further detail.

Highlighted

Take part of querystring variable and save it as a variable

SKammerlocher
Visitor
SKammerlocher

@UnknownJ thank you so much for your help. It works perfectly!!!!!