1

We're tracking the internal search keywords via analytics PageEventData api. We're looking to get the data of these tracked search keywords.

Is there any analytics api to get these tracked search keywords?

1 Answer 1

1

To retrieve tracked search keywords from the Sitecore analytics database, you need to use xConnect, which is the API for interacting with Sitecore's Experience Database (xDB). Through xConnect, you can access analytics data, including search keywords.

Here's how you might implement these steps:

using Sitecore.XConnect;
using Sitecore.XConnect.Client;
using Sitecore.XConnect.Collection.Model;

public class SearchKeywordTracker
{
    public void GetTrackedSearchKeywords()
    {
        using (var client = Sitecore.XConnect.Client.Configuration.SitecoreXConnectClientConfiguration.GetClient())
        {
            var query = client.Interactions.Where(x => x.Events.OfType<SearchEvent>().Any());
            var interactions = query.GetBatchEnumerator();
            while (interactions.MoveNext())
            {
                foreach (var interaction in interactions.Current)
                {
                    foreach (var _event in interaction.Events.OfType<SearchEvent>())
                    {
                        var searchKeyword = _event.Keywords;
                        // Process search keyword
                    }
                }
            }
        }
    }
}

Hope this helps!!

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.