how can parse the url and check for domain and path to set a number of omniture variables?

Tealium Expert
Tealium Expert

Hi All,

 

I had a requirement to parse the url and check for domain and path to set a number of omniture variables. I was wondering how can i do that. i heard that tealium has some inbuilt variables to get the domain,path, query string and hash. so i dont need to write the URL parse logic. i tried some of those like b['dom.domain] in my javascript extension. But it never worked:(.

 

E.g. 

 

URL: http://www.abc.com/about/index.html?test=1

 

my planned logic would be 

 

check the domain and path as abc.com and /about/index.html respectively, then set propxx="about ab", propyy="about bb"

 

Also i several domains and paths and the values set is kind of static values. i was thinking of using the look up table extension for looking up the values. let me know if there is any other best approach you would suggest.

 

Note: These are just example values.

 

Thank you for the help.

Thanks & Regards
--------------------------------------------------
Abraham Easo
Principal Consultant
Numeric Analytics, LLC
Bartlett, IL (CST)
m: 980-422-2044
Abraham.Easo@numericanalytics.com | http://www.numericanalytics.com
Adobe Analytics Architect/Tealium Expert/Ensighten/Google Analytics Certified
6 REPLIES 6

how can parse the url and check for domain and path to set a number of omniture variables?

Employee Emeritus

@abrahameaso

You are on the correct path, I just think you are missing a few details.  I did a quick mock up to show you some of the values based on your example, here is a screenshot

tmp-utag-20151124T093133.png

 

Two additional pieces of information you need to understand: utag is a window level object and so utag.data is a global representation of the data for that page view.  However b is a local copy of utag.data within each of the specific tags.

 

Okay with that cavate out of the way lets talk about some of the details.

utag.data["dom.domain"] equals "www.abc.com" NOT "abc.com", so I am not sure if that was creating any issues for you ( within an extension scoped to a tag, you can use b["dom.domain"] )

 

I also want to point out the difference between utag.data["dom.query_string"] and utag.data["qp.test"] 

dom.query_string will have all the query_string parameters as one long string

On the other hand, there will be 1 qp. for each of the key value pairs found in dom.query_string

In this case, we have utag.data["qp.test"] which is equal to the value "1"

 

Also the goal of Tealium is that people do not have to write JavaScript

All of the "dom" data sources in utag.data will be available as part of the drop downs within the TiQ UI.

If you want to add one of the qp. or cp. to the drop down list, you just need to add that data source and then pick the correct type:

 

tmp-utag-type-20151124T094514.png

 

Last you will need to use a Set Data Value or Lookup Extension to set some variables

Then make sure you map those variables to the tag

Here is a pretty good example of setting variables and then mapping them, the only thing you might have different is some conditional logic in the extension.

https://community.tealiumiq.com/t5/Developers/Installing-Recipe-Tracking-Pixels/m-p/9970#M4017

 

Does this help answer your question?  If you respond, please "@" me so I get an email alert.

 

 

how can parse the url and check for domain and path to set a number of omniture variables?

Gold Contributor
Gold Contributor

how can parse the url and check for domain and path to set a number of omniture variables?

Tealium Expert
Tealium Expert

@brian_kranson

 

Thanks for the clarification brian. This totally helped me understand the inbuilt tealium variables usage.

 

I think the isse with me was that, i was using  b["dom.pathname"]; on a DOM ready scope in my extension. Per your clarification it is a local variable specific to tag. So i think the reason why it was not working is due to the scope i was using. Now i changed to All Tags scope and data is showing up.

 

Regarding my question on lookup extension. i have around 400+ different rules based on the URL. Based on each rule i have to set channel and Segment. Note: There is no much relation on the values set for each url in the rule.

 

E.g.

 

Segment Name         Channel (Site Section)                    Other (?)                  URL Path                                                                 Level 2
abcorg                         about-nar                                                                            /about-nar
abcorg                         about-nar                                                                            /about-nar/nar-at-a-glance nar-at-a-glance
abcorg                         about-nar                                                                            /about-nar/national-leadership                             national-leadership
abcorg                         footer-elements                                                                 /advertise-with-nar
abcorg                         business-specialties                         index                     /appraisal appraisal

 

So if i go with your suggetion of using set data values extension, i would end up creating 400 data value cases know? i was thinking to avoid that number of extensions, which might create a lot of overload on the page.

 

I was thinking if we can store this in an array and do a lookup match on the URL to get the segment and channel and level2 variables. But currently i couldnt find any built in extension like that.

 

I could understand this is kind of a custom requirement and might not be compatible with the extensions available. Let me know if you have any thoughts on solving this problem easily.

 

What i would think is to create an extension that can create this array of 400 rows of data with key as URL path and look up through the array based on the url domain or context path to find the correct data for the specific page  URL.

Thanks & Regards
--------------------------------------------------
Abraham Easo
Principal Consultant
Numeric Analytics, LLC
Bartlett, IL (CST)
m: 980-422-2044
Abraham.Easo@numericanalytics.com | http://www.numericanalytics.com
Adobe Analytics Architect/Tealium Expert/Ensighten/Google Analytics Certified

how can parse the url and check for domain and path to set a number of omniture variables?

Employee Emeritus

@abrahameaso Give me a little time to think about the Lookup concept.  I have asked a colleague for thier advise on the topic. And I am traveling for the holiday, which will cause some delay as well.

 

I want to point out some more detail to you based on your response.

Pre Loader Scope: will execute one time per page and can only utalize utag_data and will not have access to anything withing the object utag

DOM Ready Scope: will execute one time per page and runs at the point the browser raises the DOM Ready event, can utalize utag_data and utag.data (as they are pointers to each other at the time DOM Ready happens)

All Tags Scope: will execute once for the initial page view and then once per utag.view or utag.link event, they can see the global utag_data and utag.data, however they also have a local copy called b which is what is utalized for most use cases. 

Single Tag Scope: similar to All Tags but will only execute for one tag, should always use b in this use case (I am sure there is some exception to this rule, but few and far between).

how can parse the url and check for domain and path to set a number of omniture variables?

Employee Emeritus

@abrahameaso

OK, I got a solution that I think is going to work for you.

1) You will keep all your data in Excel (with some special sauce I will share with you below)

2) You will have a Join Data Extension to get a domain/pathname variable

3) You will use this new varaible to help match with a Lookup Table

4) Next you use a Set Data Value Extension to get your 3 output variables

5) Finally you will need to map these three variables to your Tag

 

*NOTE: You can right click on any image below and open in a new tab. This will make the image larger and easier to read.

 

For the Excel File, here is the code for cell E2.  Then you can copy E2 down for all the rows in Column E

=""""&A2&""""&","&""""&B2&"|"&C2&"|"&D2&""""

tmp-lookup1-20151126T131826.png

 

tmp-lookup2-20151126T132205.png

 

tmp-lookup3-20151126T132455.png

 

tmp-lookup4-20151126T132707.png

 

The next step has some JavaScript that will split on the pipe symbol and create three new output variables

b['lookup_match'].split('|')[0]
b['lookup_match'].split('|')[1]
b['lookup_match'].split('|')[2]

tmp-lookup5-20151126T132820.png

 

I am using the Acme Tag to do the mapping because that is one that was in my profile.  You will have to map to the correct tag based on your use case.  And because of that your destination names will also be different.  

 

tmp-lookup6-20151126T133156.png

 

Let's look at 2 test pages:

tmp-lookup7-20151126T133531.png

 

tmp-lookup8-20151126T133858.png

 

Please let us know how this works out for you.  Kinda fun to think about how you can glue all the parts of Tealium together.


Brian

how can parse the url and check for domain and path to set a number of omniture variables?

Tealium Expert
Tealium Expert

@brian_kranson

 

This worked like a charm!!!! Brian Thank you and really appreciate your help in this.

 

I did tried out this with a set of my URLs and it worked well. i will be working to scale it up to my 400+ rules.

 

This is a very interesting conversation which helped me learn more features about tealium

 

1) Lookup Table usage based on domain & context path and match returning multiple values concatenated

2) Set Data values extension with java script code.

3) Preparing the CSV for lookup table etc...............................

 

 

Thanks & Regards
--------------------------------------------------
Abraham Easo
Principal Consultant
Numeric Analytics, LLC
Bartlett, IL (CST)
m: 980-422-2044
Abraham.Easo@numericanalytics.com | http://www.numericanalytics.com
Adobe Analytics Architect/Tealium Expert/Ensighten/Google Analytics Certified
Public