Gravatar for hussaindotnet@gmail.com

Question by Hussain Shaik, Mar 6, 2018 1:33 PM

Coveo analytics CLICK event is firing but no data captured at Coveo Cloud

I am using Coveo JS to send Coveo analytics events to Coveo cloud. I have used "sendClickEvent"

by sending required data. I am getting response output but not able to find the event at Coveo Cloud UI.

I wait for 2 hours but there is no luck at Coveo cloud. Any issue with the below code?

The below is the sample code :

 var coveoAnalyticsclient = new coveoanalytics.analytics.Client({
            token: 'KEY'
        });
var customData = { Key1:'somedata', };
coveoAnalyticsclient.sendClickEvent({ eventType: "sendClickEvent", eventValue: "1", language: "en", actionCause: 'click', documentUri: 'http://xyz.com/url/10007', documentUriHash: "uCBw0OO4s9ERSU6Q", collectionName: 'default', searchQueryUid: data.searchUid, documentPosition: 1, originLevel1: "Search", customData: customData, sourceName: 'Coveo Source Name' });

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Mar 8, 2018 10:42 AM

Is this in a Coveo for Sitecore page that includes the CoveoAnalytics component?

2 Replies
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Mar 8, 2018 11:29 AM

Hi Hussain,

If you are using Coveo JavaScript Search Framework for your UI, you probably have a CoveoSearchbox component and are displaying your results in a CoveoResultList component with some result templates.

If your search interface include a CoveoAnalytics component, it will take care of sending all the usage analytics event calls for you. All the Coveo JavaScript Search Framework components are analytics aware.

In your result templates, you should use the CoveoResultLink component for the anchor around result titles. This component will take care of sending the click usage analytics event for the clicked result before navigating in the browser.

Gravatar for hussaindotnet@gmail.com

Comment by Hussain Shaik, Mar 8, 2018 1:06 PM

I don't have CoveoSearchbox component. What i have is

1. Simple search box

2. Clicking on it , get Coveo search results as JSON bu using Coveo Cloud end point

3. Iterate the data and add TILES with titles in it.

4. Clicking on each title, need to send click event by using the above code.

Questions :

1. I am getting back response as

{"visitId":"09f61c29-2224-468e-bad6-12b29ced3373","visitorId":"9475b711-2be3-4d96-bebd-6d5606dd0e56"}

But not able to find the data in Coveo CLoud "Visit Browser" section.

i am following this link

https://docs.coveo.com/en/18/cloud-v2-api-reference/usage-analytics-write-api#operation/post__v15_analytics_click

Gravatar for lbourdages@coveo.com

Answer by lbourdages, Mar 8, 2018 9:18 PM

Hi!

As a preface, a bit of information regarding click events. In Coveo Usage Analytics, a click must always be preceded by and related to a search event. This is to ensure that the analytics data stays coherent - there cannot be any documents to click if there wasn't a search to start with. We use the "searchQueryUid" field in both the search and click events to link them together.


Now, looking at your code sample, there does not seem to be a search event sent before you send the click. Is that the case? If so, your fix is simply to send a search event, then use the searchQueryUid of the search in your click event.

You can verify why your events do not end up in the visit browser by using the following API call:

https://usageanalytics.coveo.com/docs/read/#!/Statistics_API_-_Version_15/get_v15_stats_incoherentEvents

This allows you to see events that were rejected and the reason behind their rejection. In your case, I suspect it would be "CLICK_WITHOUT_ASSOCIATED_SEARCH".

As Jean-François said, it is simpler to use the Coveo JS Search Framework because it automatically manages analytics events for you.

Gravatar for hussaindotnet@gmail.com

Comment by Hussain Shaik, Mar 9, 2018 12:54 PM

Hi, Yes you are correct. If i send correct/previous search id then i am able to get the data at Coveo Cloud side.

One note , data is getting even if i send some random id as search id. Any impact if i send random id ?

Ask a question