NOTE: If your looking for the article on Omniture & ColdFusion: Why you should care. Click Here. I botched the link in the original tweet.
I was reading a post on WebAnalyticsLand about a SiteCatalyst plugin to populate the s.hierN variables from the URL, and it got the gears turning. I wonder if I could get that to work using a combination of ColdFusion & JS instead of just making edits to the s_code file.
Some things to consider before implementing Hierarchies: (swiped from Omniture’s Manual)
- There are five hierarchy variables available, which must be enabled by Omniture ClientCare.
- At the time the hierarchy is enabled, you will need to decide on a delimiter for the variable and the maximum number of levels for the hierarchy.
- Before implementing hierarchies, refer to the Channels and Hierarchies white paper.
- The delimiter may not be changed once the hierarchy is setup. If the delimiter for your hierarchy must be changed, contact Omniture ClientCare.
- The number of levels may not be changed once the hierarchy is set up.
Once the hierarchy is activated, you should see it in SiteCatalyst under the Site Content Menu item (In version 14.6)
That concludes the configuration portion of the adventure. Now to the coding!
Note: I code in a ColdFusion environment in which I have a .cfm page that pulls the s_code.js into it so I can use some built in CFML functions to tweak the data.
Goals for this adventure were to:
- Dynamically set the s.hierN variable on every page
- Prevent levels greater than 5 from being passed
- Prevent filenames being passed as levels (index.cfm)
- And of course..get it all working to provide a hierarchical view of our web traffic. 🙂
<cfset variables.omniHierList = cgi.path_info > <cfset variables.omniHierListLen = ListLen(variables.omniHierList,"/")> <cfset variables.newOmniHierList = ListChangeDelims(variables.omniHierList,"|","/")> <!--- Check the list len to make sure we do no exceed the level depth ---> <cfset variables.lastItem = ListGetAt(variables.newOmniHierList,variables.omniHierListLen,"|")> <cfif FindNoCase(".","#variables.lastItem#") GT 0> <cfset variables.newOmniHierList = ListDeleteAt(variables.newOmniHierList,variables.omniHierListLen,"|")> </cfif>
This will result in: Assuming of course that your current path is “/root/evil/browsers/IE6/demonspawn/use/firefox.ftw”
So what I’ve done is parse through the cgi.path_info variable, change the delimiter to | and removed the filename from the end of the list. But as you can see I am left with a list of 6 items and I can only send 5 levels to the s.hier I had ClientCare activate. I was told that the extra’s would be ignored, but I do not like to leave things to chance, so I added one more set of code.
<cfif variables.omniHierListLen GT 5> <cfset variables.newOmniListTrim = ""> <cfloop from="1" to="5" index="i"> <cfset variables.newOmniListTrim = ListAppend(variables.newOmniListTrim,ListGetAt(variables.newOmniHierList,#i#,"|"),"|")> </cfloop> <cfset variables.newOmniHierList = variables.newOmniListTrim> </cfif>
Now you have a list of a max of 5 items to set the s.hierN variable to.
This was one of the easier Omniture adventures so far!