Search code examples
sitecoresitecore6sitecore-dms

Sitecore track page clicks


I'm building a website in Sitecore and we have a FAQ page that consists of a series of headers with associated divs that hide/unhide as they are selected. I've been asked to track these header clicks so that we can sort the FAQ items on the page. How would I go about storing this click information in Sitecore Analytics?

I've found many questions and answers about how to query Sitecore's default page-load behavior, but how would I go about tracking how many times a particular div has been viewed?


Solution

  • Assuming you're using DMS, you should be able to configure goals that correspond to each header section. You may have to trigger the completion of the goal in code:

    if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.CurrentPage != null)
    {
            PageEventData eventData = new PageEventData("My Goal Name");
            eventData.Data = "this is some event data.";
            VisitorDataSet.PageEventsRow pageEventsRow = Sitecore.Analytics.Tracker.CurrentPage.Register(eventData);
            Sitecore.Analytics.Tracker.Submit();
    }
    

    Then you just have to look at your reports to see how effective each FAQ section is.

    Hope this helps.