Tracking Local Search with DMS


February 9, 2012 by Alistair Deneys

Sitecore’s Digital Marketing Suite (DMS) comes with some handy reports out of the box for analysing searches your users are performing on your Sitecore site. There’s both a high level report in the executive dashboard for site wide searches and also item reports for checking search terms leading to an item and searches performed on an item.

All these reports assist in helping you work out what people are looking for on your site and also when they can’t quite find the information they’re after when the arrive at an item.

But Sitecore doesn’t magically know what actions on your site constitute a user search. So we have to register that action ourselves. The way we do this is by registering a page event for the search page event which ships with DMS and the search reports are written to report on.

I remember from the Online Marketing Suite (OMS) days there used to be a helper method for doing this. OMS contains an extension method for the AnalyticsPage class in the Sitecore.Analytics.Extensions.AnalyticsPageExtensions namespace called Search. We can call it by using the following code:

  AnalyticsTracker.Current.PreviousPage.Search(query, m_totalResultCount);

The above code would be called from the search results page. Note however that we register the search page event against the previous page where the search would have been entered by the user.

But with DMS I had a hard time finding the equivalent method. The above extension method is actually just a convenience method which registers the proper OMS page event. So with DMS, we just have to register the page event ourselves.

The following code registers the search page event by name.

if (Tracker.IsActive &&
  Tracker.Visitor != null &&
  Tracker.Visitor.CurrentVisit != null)
  var page = Tracker.Visitor.CurrentVisit.CurrentPage;

  if (Tracker.Visitor.CurrentVisit.PreviousPage != null)
    page = Tracker.Visitor.CurrentVisit.PreviousPage;

  page.Register(new PageEventData("Search")
    Data = query,
    DataKey = query,
    Text = query

Again, note how the page event is registered against the previous page, not the current one which would be the search results page (though I’m defaulting to the current page in the event the previous page is null).

I mentioned that the event is registered by name. DMS loads the page events defined in Sitecore and will find the event by name when the PagesRow.Register() method is called.

With the above code in place, we’ll now be capturing analytics data for search actions on the website.


Here’s a handy tip, if after you’ve implemented the above code you still don’t see any data showing up in the search reports, trying changing the MinimumVisitsFilter value in the sitecore/shell/Applications/Reports/Dashboard/Configuration.xml file. With the default value of 50 in this setting you’ll need 50 different visits before any data shows in the report.


10 thoughts on “Tracking Local Search with DMS

  1. Lieven says:

    Nice to know about the config XML file. Thanks!

  2. Ivan Huang says:

    Thanks Al, that saves lots of my time, the method in the Sitecore document looks too complex.

  3. Please excuse my ignorance as I’m finishing up my first Sitecore implementation. But I had two questions about the code snippet:

    1) Does it go in the search results page sublayout codebehind?
    2) Where do the ‘query’ variable come from?

    Many thanks

    • Alistair Deneys says:

      Hi Joe,
      Yes, the code would go in your search results codebehind or wheverever you’re executing the search logic. The “query” variable in my example was parsed from the keywords entered by the user. If you were using a textbox you could populate from it from the “Text” property or if you’re using a query string parameter read the variable from the HttpContext.Current.Request.QueryString object.

  4. mahendra says:

    hi Alistair, i just tried to tracking the local search using sitecore DMS according to this blog. i create a RegisterSearchPageEvent and use it in my search page sublayout cobe behind. now when running the page it add the search keyword into database but when go to exclusive dashboard in sitecore it doesn’t show any thing. i also change the MinimumVisitsFilter value

  5. Abhishek says:


    I have performed all the steps mentioned in the blog, I have checked that Analytics database is tracking the search keywords but reports doesn’t show any records.
    Any one have idea for how much time it will take to reflect search keywords in reports?
    In my case, reports not showing any records,

    • Alistair Deneys says:

      Hi Abhishek,
      Did you check the advice I gave at the bottom of the post about the Configuration.xml file?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


The views expressed on this blog are solely my own and do not necessarily reflect the views of my employer.
%d bloggers like this: