Omniture SiteCatalyst Helpful Tip – Dynamically Build Hierarchy Variable
Hierarchy variables provide great insight into what users are doing on your site. However, manually passing in information or trying to build it off of other variables can become cumbersome and a challenge to manage and maintain.
Building this variable dynamically lessens the burden and makes maintenance much easier. Below, I describe (with the necessary code) how to tackle this:
- Within the doPlugins section of the s_code.js file, please add the following line:
/* Dynamically Capture Hierarchy Variable via Custom Plugin */
s.hier1=set_hier1();
- Next within the plugins section, add the following snippet of code:
/*
* Custom Plugin: Dynamically Create s.hier variable
*/
function set_hier1() {
h1 = new String(document.location.host + document.location.pathname);
if(h1.charAt(h1.length-1)==”/”) {
var temp = new String();
for(var i=0;i<h1.length-1;i++){ temp += h1.charAt(i); }
h1 = temp;
}
var intMatch = h1.indexOf(“/”);
while (intMatch != -1) {h1 = h1.replace(“/”,”|”);intMatch = h1.indexOf(“/”);}
return h1;
}
Now with this in place, you can allow your hierarchy variable to be built off of the corresponding URL which not only saves you time for implementing a custom solution but also centralizes the collection of this data to the s_code.js file (versus say the header and s_code file).
Written by:
Dorian D. Regester
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

