Friday, November 9, 2018

Track your Internal Search Keywords Using Sitecore Analytics




In the Digital ERA, everything is now measurable, Everybody wants to know their customer behavior on the website and keyword search is the most important element in this aspect to know what exactly customer is searching or looking on the website, through tracking these keywords information, marketers can further optimize the pages/visuals/lead/forms/Sitemap/personalization’s/ rules etc.  To provide better customer experience and get more conversions.


Again, “Internal Search” feature is the hidden gems feature in the Sitecore analytics, Must say Sitecore cares the current digital marketers and provides such a “must have” feature in the Sitecore analytics out of the box.

I didn’t know this feature, and wanted the track all the keyword search on my website, to check “what exactly people are searching on my website”
But the question is how? How to track all the keyword of the website search that customers are searching? Do I need to store in the database? And do some basic reporting, or track all the pages with query string? and provide the unique report? Was totally confused and planning to build my custom module for the same.

But after scratching my head a bit and some googling , I came to know the feature called “Internal Search” in the Sitecore out of the box. Cool, then why should I reinventing the wheel, if  Sitecore has already invested and provided as a feature.

But the problem was how to configure this search tracking functionality in the analytics, by default it’s not implemented and showing blank as below.



Then again after doing some research I figured out the solution, and now I can track my keyword search and here is the results:

But….

Guess, who is the most searchable person by the Sitecore community members on my website?



 Yes, Akshay Sura and Kamruz Jaman are the top keyword search on my website, see how important this feature is? Now I can track my keywords search like anything – Real time..


 




Solution – How to configure the Internal Search keywords tracking in Sitecore Analytics:

For the demo purpose, I just created a simple search.aspx page which consists of textbox and button,






I am searching the keywords using the above textbox and click on the search me button, then I am calling sitecore analytics API to register the keyword.

 Register the search page event in the Sitecore Aanalytics tracker


        protected void Button1_Click(object sender, EventArgs e)
        {
           
            var searchEvent = Tracker.MarketingDefinitions.PageEvents[AnalyticsIds.SearchEvent.Guid];
            string searchKeyword = string.Empty;
            searchKeyword = TextBox1.Text.Trim();
            Sitecore.Analytics.Tracker.Current.CurrentPage.Register(new PageEventData(searchEvent.Alias, searchEvent.Id)
            {
                Data = searchKeyword, Text = searchKeyword
            });

        }

here is the form page, don’t forget to add visitor identification tag on the page:


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="Search.Search" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            Enter Search Keyword :
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

            <asp:Button ID="Button1" runat="server" Text="Search Me" OnClick="Button1_Click" />

        </div>
    </form>
    <sc:VisitorIdentification runat='server'/>
</body>
</html>

Here is the code behind:


using Sitecore.Analytics;
using Sitecore.Analytics.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Search
{
    public partial class Search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
           
            var searchEvent = Tracker.MarketingDefinitions.PageEvents[AnalyticsIds.SearchEvent.Guid];
            string searchKeyword = string.Empty;
            searchKeyword = TextBox1.Text.Trim();
            Sitecore.Analytics.Tracker.Current.CurrentPage.Register(new PageEventData(searchEvent.Alias, searchEvent.Id)
            {
                Data = searchKeyword, Text = searchKeyword
            });

        }
    }
}

Really cool and quick to start the POC and implement the above code based on your solution and code:

Now, deploy your page into your Sitecore instance and hot the search page URL something like http://suguae.sc/search.aspx in your case, replace your domain name:

Search some keywords and hit search button and behind Sitecore will track all the keywords which you are searching.

Change the session timeout setting from the web.config to quickly test the functionality otherwise you have to wait 30 minutes to refresh the results,

<sessionState mode="InProc" cookieless="false" timeout="1" sessionIDManagerType="Sitecore.SessionManagement.ConditionalSessionIdManager">      <providers>      

Now all done, let’s check the Analytics:

Go to the analytics dashboard: 




Go to internal search under Behavior tag on the left hand side panel




Now you can able to see all your keyword tracking based on your search page here, also you can generate multiple reports based on multiple Metric – Page view, counts, Visits etc. further you can filter the date based report using time range etc..




I found this feature very important and relevant, and everything is built-in with minimum code change.

I hope you like this article  will help you to start thinking and exploring the Keyword search with Sitecore.

Happy Sitecoring..  

Configure Sitecore 9.1 Content Tagging feature with Open Calais

What is Tagging? Tagging refers to the metadata of the content which is assigned to a content by the content creator and the r...