I have manually trigger a search event based on Sitecore in standart way:

var searchEvent = Tracker.MarketingDefinitions.PageEvents[AnalyticsIds.SearchEvent.Guid];

Sitecore.Analytics.Tracker.Current.CurrentPage.Register(new PageEventData(searchEvent.Alias, searchEvent.Id)
    Data = "sitecore experience platform"

but after I need to find the most popular or latest search, not for one specific ContactReference, but globally by site. how I could do it programmatically ?

1 Answer 1


To get all SearchEvents you will need to make a call to XConnect.

Something like this should do the trick:

using (XConnectClient xConnectClient = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient())
    var searchs = new List<SearchEvent>();
    Guid SearchDefinitionID = new Guid("0c179613-2073-41ab-992e-027d03d523bf");
    var interactions = await xConnectClient.Interactions.Where(interaction => interaction.Events.Any(ev => ev.DefinitionId == SearchDefinitionID)).ToList();
    foreach (var interaction in interactions)
        foreach (SearchEvent ev in interaction.Events.Where(ev => ev.DefinitionId == SearchDefinitionID).ToList())

If you are going to be doing regular data extraction and processing from XConnect. I believe it is recommended to use the Sitecore Cortex engine and its projection framework:


You could use this to project, group and count data as required. This uses distributed workers, so can be alot faster and more efficient.

I found this to be a great resource if you are interested in the above: https://github.com/adeneys/cortex-processing-demo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.