Highlighted

Creating a JavaScript Variable

Silver Contributor
Silver Contributor

Hi, 

 

I want to set a javascript variable using the "add variable" option. I can set the following 

utag.cfg.path as a JS variable - but NOT utag.data['dom.domain'] because of special characters are not allowed.

 

Is there a way to repurpose all the data that is available under utag.data - e.g. meta and dom data?

 

Thanks

7 REPLIES 7
Highlighted

Creating a JavaScript Variable

Tealium Employee

@zhaque

 

The domain is a pre-declared variable so there is no need to re-declare it. If you are creating a load rule, mapping a data variable in a tag, or using an extension, you can simply type in "domain" in the drop down and it will automatically appear for use. 

 

domain.png

 

Please let me know if you are attempting to use domain somewhere else and I can give proper guidance.

 

Cheers,

-Dan

Highlighted

Creating a JavaScript Variable

Silver Contributor
Silver Contributor

Thanks @dan_george for your answer. I would like to use it in the extension. I wanted to picup a query parameter CID from the URL and save it in the variable. The extension I was thinking of using is the Set Data Value and Join Data Value. 

 

Example as per your instructions in the "Set Data Value" externsion I will select "querystring" from the drop down but how do I just pickup CID and populate a new variable? Do I need to use the javascript extension? in such case how do you access "querystring"? 'qp.cid'

 

Cheers

Highlighted

Creating a JavaScript Variable

Tealium Employee

@zhaque

 

If you are just attempting to pick up a querystring parameter out of the URL, you can just declare the QSP in the Data Layer tab:

  1. Go to Data Layer tab
  2. Click green "Add Variable" button
  3. Input "CID" as the source (case sensitive)
  4. Choose "Querystring Paramter" as the type
  5. Apply the new variable

That's it! And now it will be accessible through the rest of the UI.


If you plan to map it in a tag, or leverage within an extension, this is all that is required to reference it. Please let me know if this is the guidance you are looking for.

 

Cheers,

-Dan

Highlighted

Creating a JavaScript Variable

Silver Contributor
Silver Contributor
Many Thanks Dan!!

Got to finish my video training soon :)

Creating a JavaScript Variable

Bronze Contributor
Bronze Contributor

I have a related question, I would like to create a first-party cookie in Tealium  that contains all the utm params. In the UI, I could not find a way to assign/concatenate multiple query parameter variables to do so. So I am planning to write an extension that takes in the dom.query_string and parses it out to store the output in a single udo.data variable. How do I refer to udo.data[dom.query_string] in extensions?

 

Highlighted

Creating a JavaScript Variable

Gold Contributor
Gold Contributor

Hi @dgho3174 ,

You could use JoinDataValues extension to concantenate multiple paramters. Since it is a query sting paramter you can use the method suggested by @dan_george .

Once you have created a Query string paramter variable you can use it in the extension.  Please Find the extension below.

You should create a UDO variable for the destination in JoinDataValue extension.

Join Data values.JPG

If you want to reference the 'Query string paramater' values in javascript extension you can use

b['qp.utm_campaign] or utag_data['qp.utm_campaign']

 

Thanks

VJ

Its Not Who I am Underneath, but What I Do That Defines Me
Highlighted

Creating a JavaScript Variable

Bronze Contributor
Bronze Contributor
Thank you, this is exactly what I was looking for.