website logo
Product FeedCommunity Forum
API Docs
Template JS
Headless SDK
Navigate through spaces
API Docs
Template JS
Headless SDK
⌘K
Introduction
Getting Started
Quickstart : Smart Search
Quickstart : Smart Category Merchandising
Quickstart : Smart Recommendations
Apps/Plug-ins
Guide
Structure
Configuration
JS Library
Versioning
Template Reference
Build UI
Custom Overrides
Recommendations Webhooks
Styling CSS
Analytics/Tracking
How To
Add Filters To URL
Add Pagination To URL
Add-To-Cart Function
Customer Groups
Infinite Scroll Results
Magento B2B MSI
Ratings / Reviews
SortBy Options
Docs powered by archbee 
19min

Analytics/Tracking

With Klevu Template JS already include the majority of analytics requirements out of the box.

If you are modifying the templates in any way, it is still important to understand the contents of this page, and validate your integration against the requirements below.

It is one of the key drivers behind Klevu Machine Learning; tracking customer searches and clicks to feed into our AI for relevant search results based on real customer interactions.

Analytics collection is required for all integrations and should not be considered an optional element



This page covers the minimum requirements for Klevu analytics. You may also decide that other interactions such as product views or interactions elsewhere in your website constitute a ‘click’, so you could also submit those if you choose.

Analytics on Modified Templates

If you are using a modified version of a productBlock Template(s), be aware of the required class selectors for Analytics tracking event listening. (this is a common oversight when extensively modifying the template).

QuickSearch Product <li class="klevuProduct trackProductClick kuTrackRecentView" data-id="<%=dataLocal.id%>"> SearchResults Product <li class="klevuProduct klevuProductClick kuTrackRecentView" data-id="<%=dataLocal.id%>"> Other Product Link <a class="klevuProduct klevuProductClick kuTrackRecentView" data-id="<%=dataLocal.id%>" > Recommendations Templates <li class="kuRECSItem" data-id="<%= item.id %>"> <a class="kuRECSItemClick kuRECSImg" data-id="<%= item.id %>" >

If you elect to not use Klevus built-in analytics collection events, the sections below can assist in setting up a system that fits your architecture the best

Template JS Analytics event listeners are not responsible for order/checkout/purchase data. This call must be implemented during your platform checkout processing. See Orders Placed section below



Analytics Events

The following is a list of tracking events that are required in any Klevu implementation:

  • Searched terms.
  • Products clicked.
  • Orders placed.

These events must be tracked in all areas of your store which contain a Klevu implementation, including:

  • Quick Search.
  • Search Results Landing Page.
  • Category Pages using Klevu Smart Category Navigation.
  • Landing Pages built with Klevu Landing Page Builder.

Searched Terms

When the customer enters a search query, either via quick search or when reaching your search results landing page, it is important to inform Klevu of this activity.

This is detailed in the Klevu API Documentation and looks like this:

https://stats.ksearchnet.com/analytics/n-search/search ?apiKey=klevu-1234567890 &term=red%20shoes &klevu_totalResults=35 &klevu_typeOfQuery=WILDCARD_AND

No Results Found

Even if the customer types in a query that yields no results, you should still send the analytics tracking request to Klevu. The important element to inform Klevu of a ‘no results found’ query is klevu_totalResults=0. This applies to both quick search and the search results landing page.

https://stats.ksearchnet.com/analytics/n-search/search ?apiKey=klevu-1234567890 &term=red%20shoes &klevu_totalResults=0 &klevu_typeOfQuery=WILDCARD_AND

Category Page Views

When the customer visits a category page powered by Klevu Smart Category Navigation, it is important to inform Klevu of this activity.

This is detailed in the Klevu API Documentation and looks like this:

https://stats.ksearchnet.com/analytics/categoryProductViewTracking ?klevu_apiKey=klevu-1234567890 &klevu_categoryName=Sneakers &klevu_categoryPath=Mens%3BShoes%20and%20Trainers%3BSneakers &klevu_productIds=54321-12345%2C345 &klevu_pageStartsFrom=0

Products Clicked from Search

Once a customer has used quick search, viewed a search results page or landed on a klevu powered landing page, it is important to capture any product interactions they go on to make.

This is detailed in the Klevu API Documentation and looks like this:

https://stats.ksearchnet.com/analytics/productTracking ?klevu_apiKey=klevu-1234567890 &klevu_keywords=red%20shoe &klevu_type=clicked &klevu_productId=54321-12345 &klevu_productName=Smart%20Trainers &klevu_productUrl=https%3A%2F%2Fyour.website.com%2Fproduct-url

Products Clicked from Category Pages

Once a customer has viewed a category page powered by Klevu Smart Category Navigation, it is important to capture any product interactions they go on to make.

This is detailed in the Klevu API Documentation and looks like this:

https://stats.ksearchnet.com/analytics/categoryProductClickTracking ?klevu_apiKey=klevu-1234567890 &klevu_categoryName=Sneakers &klevu_categoryPath=Mens%3BShoes%20and%20Trainers%3BSneakers &klevu_productId=54321-12345 &klevu_productName=Smart%20Trainers &klevu_productUrl=https%3A%2F%2Fyour.website.com%2Fproduct-url &klevu_productSku=ABC-123 &klevu_salePrice=123.45 &klevu_productRatings=3 &klevu_productPosition=7

Orders Placed

The final analytics data required is when a customer makes a purchase.

If you are using the Klevu plugin for Magento, Shopify or BigCommerce, the order tracking analytics is already taken care of for you via a server-side implementation. 

Important : Please do not add a frontend implementation if you are using one of the these plugins, as this would result in duplicate analytics requests.



If you are not using one of our plugins then you have two options for sending the transaction analytics data to Klevu:

  1. A server-side implementation via a scheduled task.
  2. Via a frontend implementation, eg. on the checkout success page.

The API call is the same for each approach, and is detailed in the Klevu API Documentation. It is up to you which you choose, but please only choose one. The analytics request looks like this:

https://stats.ksearchnet.com/analytics/productTracking ?klevu_apiKey=klevu-1234567890 &klevu_type=checkout &klevu_productId=54321-12345 &klevu_unit=2 &klevu_salePrice=123.45 &klevu_currency=GBP

This API call must be made for each product purchased.

This tracking event is the same regardless of whether the customer used search or category navigation.

Please submit all orders to Klevu, even if the customer didn’t use search or visit a category page.

Testing

In order to know whether each of the tracking calls is working, you will get immediate feedback from the API response, which will look like this for successful requests:

<data> <response>SUCCESS</response> </data>

After a day or so you will start to see the analytics data appearing in the Klevu Merchant Centre, as the analytics data you provide is not processed in realtime and instead handled in batches due to the various calculations involved.

Updated 03 Mar 2023
Did this page help you?
Yes
No
UP NEXT
Add Filters To URL
Docs powered by archbee 
TABLE OF CONTENTS
Analytics on Modified Templates
Analytics Events
Searched Terms
No Results Found
Category Page Views
Products Clicked from Search
Products Clicked from Category Pages
Orders Placed
Testing