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, piding purchase by view and multiplying by 100. We use the round function of eval to eliminate decimal places, and then we tack on the % character at the end. Now, we can easily see what percentage of views lead to cart additions.