Track Hash Query Parameters in Omniture SiteCatalyst

Do you have a site that uses a hash symbol in the URL with query parameters and you want a way to track them in SiteCatalyst? Well you have come to the right place.

What am I talking about? Lets say you have a URL that looks like this:
and you want to capture the value of cid=. The standard getQueryParam plugin will not work in this case. It looks for a question mark in the URL, and as you can see this one did not have one.

To capture this value we can use the getHashQueryParam s_code.js plug-in. What this plug-in does is looks for the hash symbol # at the end of the URL, then looks for the parameter you have listed in the function, then inserts the value in to the associated variable. This works just like the standard getQueryParam plugin, but looks for the hash instead.

Here’s how to use it. Insert this line of code in the s_doPlugins(s) section of your s_code.js file. Make sure you use the correct variable you want the metrics recorded in and which query string you want it to be associated with. I’m using s.prop17 and cid in this example.


Next enter this code in the plug-in’s section of your s_code file:

 * Plugin: getHashQueryParam
function getHashQueryParam(a){
if(QueryString==''){var WinExtra=window.location.hash;
if(WinExtra.length > 0){if(WinExtra.indexOf(a)>-1){
var returnValue='';var keyValPairs=QueryString.split('&');
if(!keyValPairs){ keyValPairs = new Array();  
for(var counter=0;counter<keyValPairs.length;counter++){
var keyVal=keyValPairs[counter].split('=');if(keyVal[0]==a){
returnValue=keyVal[1];break;}}return returnValue;}

Here is an example of it live in action. After you click on the link, open the debugger you will see the value entered in s.prop17.


Leave a Reply