Create an overlay chart and explore visualization options
In this example, you create a chart that overlays two data series as lines over three data series as columns. The overlay chart will show the Actions and the Conversion Rates.
You will use the stats
command to count the user actions. The eval
command is used to calculate the conversion rates for those actions. For example, how often someone who viewed a product also added the product to their cart.
Prerequisite
This example uses the productName
field from the Enabling field lookups section of this tutorial. You must complete all of those steps before continuing with this section.
Steps
- Start a new search.
- Change the time range to All time.
- Run the following search.
sourcetype=access_* status=200 | stats count AS views count(eval(action="addtocart")) AS addtocart count(eval(action="purchase")) AS purchases by productName | eval viewsToPurchases=(purchases/views)*100 | eval cartToPurchases=(purchases/addtocart)*100 | table productName views addtocart purchases viewsToPurchases cartToPurchases | rename productName AS "Product Name", views AS "Views", addtocart as "Adds To Cart", purchases AS "Purchases"
The
eval
command is used to define two new fields. These fields contain the conversion rates.- The viewToPurchases field calculates the number of customers who viewed the product to the number of customers who purchased the product. The calculation returns a percentage.
- The cartToPurchases field calculates the number of customers who added the product to their cart to the number of customers who purchased the product. The calculation returns a percentage.
- The next few steps reformat the chart visualization to overlay the two data series for the conversion rates, onto the three data series for the actions.
- Click the Visualization tab.
- This is the same chart in Create a basic chart, with two additional data series, viewsToPurchase and cartToPurchase.
- Click Format and X-Axis.
- Look at the numbers on the Y-Axis. They range from 1000 to 3000. Click Format and Y-Axis.
- To make the chart easier to read, add a label and specify different number intervals on the Y-Axis.
- Look at the legend. It shows that some of the columns represent actions and some columns represent conversion rates.
- To fix this issue, click Format and Chart Overlay.
- To separate the actions (views, adds to cart, and purchases) from the conversion rates (viewToPurchases and cartToPurchases), you can overly one set of values over another set of values. In this example you will overlay the conversion rates, as lines, over the actions, which will remain as columns.
- For Overlay, click inside the box. Begin and select viewsToPurchase. Click inside the box again and select cartToPurchase.
- For View as Axis, click On.
- For Title, choose Custom
- Type
Conversion Rates
. - For Scale, click Linear.
- For the Interval type
20
. For the Max Value type100
. - Close the Format dialog box. Notice that the conversion rates now appear as lines in the chart.
- The axis on the right side of the chart is called the second Y-Axis. The label and values for the line series appear on this axis.
- Click Save As and select Report.
- In the Save Report As dialog box, for Title type
Comparison of Actions and Conversion Rates by Product
. - For Description, type
The number of times a product is viewed, added to cart, and purchased and the rates of purchases from these actions.
- In the Save Report As dialog box, for Title type
- Click Save
- In the confirmation dialog box, click View.
Next step
Create a report from a custom chart
See also
stats command in the Search Reference
eval command in the Search Reference
Chart overview in Dashboards and Visualizations
Create a basic chart | Create a report from a custom chart |
This documentation applies to the following versions of Splunk® Enterprise: 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.0.4, 7.0.5, 7.0.6, 7.0.7, 7.0.8, 7.0.9, 7.0.10, 7.0.11, 7.0.13
Feedback submitted, thanks!