Posted on by & filed under analytics, javascript.

It’s helpful to know how users refine their search after they land on a search results page. As I was implementing tracking to do this I struggled to find clear documentation on the web, so in this post I’m going to highlight some of the code I used. Hopefully this will be useful for others with similar problems.

The Problem

I wanted to know what refining elements are important for our users when they filter their search results.

The links I wanted to track are found on the Search Results page; see the light blue box on the left. I’m less concerned with the content of individual links (publication year of 2013, or ‘Christopher Negus’ as an author), and more with the type of filter the user is clicking (‘Category’, ‘Publication Year’ etc).

The challenge was that, for various reasons, I couldn’t add any hooks or any other code directly onto the page. Also, the filter clicks result in AJAX calls so the normal combination of Omniture link tracking and pathing wouldn’t give me the data I need.

The Solution

The answer was available in the link; the filter type was populated as a query string parameter in the href of the anchor. Although the content loads without a page refresh, I could still capture data when the anchor is clicked.

All I had to do was add some code to the plugin section of our s_code.js file:

First, I assigned each parameter to a filter type…

and then grabbed the link that the user clicks using one of Omniture’s  utility plugins:

The ‘aha’  moment was using the s.getQueryParam function to look for our parameters in the link’s query string. Typically, this function is used to grab campaign tracking codes from referring URLs. However, with the addition of a second and third argument you can grab strings from any URL you specify:

(The second argument of the function defines a delimiter for multiple parameters, but I didn’t need it in this case so left it empty)

Usually for custom link tracking in Omniture you need to fire off the function to create an image request. As this is already created when the AJAX request is made, the new eVar and Prop values were set as part of that request.

And here we are, lovely data populated in a Site Catalyst report:
Chart showing Safari Books Online search filter results in Site Catalyst

Even better, as I set the variables in an eVar, I could break down individual search terms by how users filter them.


Comments are closed.