Searching for the percentage of cart additions from product views

We can further amend the search from this recipe to evaluate a new column that calculates the percentage of product views being added to the cart. We do this using the eval command and some basic math as follows:

index=main sourcetype=access_combined uri_path="/viewItem" OR uri_path="/addItem" status=200  | dedup JSESSIONID uri_path item | chart count(eval(uri_path="/viewItem")) AS view, count(eval(uri_path="/addItem")) AS add by item | sort - view | head 10 | eval  cart_conversion=round(add/view*100)."%"

We firstly evaluate a new field called cart_conversion and then calculate the percentage, dividing purchase by view and multiplying by 100. We use the round function of eval ...

Get Splunk Operational Intelligence Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.