In my last post, I described a simple solution to track out-of-stock products using Adobe Analytics. As its name implies, this is a rather simple approach: you just get a count of the number of times an out-of-stock product is shown. For many, that might be enough, but there are many different requirements for a one-size-fits-all solution.
Another of my customers wanted a more detailed view of the stock level for all products, not just the fact that a product is out of stock. For this solution, we are going to need three events:
- event1: stock level
- event2: stock check
- event3: out of stock
The implementation, in theory, should be very simple. For example, let’s consider a page with three products:
- SKU1: more than 10 products in stock
- SKU2: 7 products in stock
- SKU3: out of stock
The code would look like:
s.products = ";SKU1;;;event1=10|event2=1,;SKU2;;;event1=7|event2=1,;SKU3;;;event3=1";
s.events = "event1,event2,event3";
In this example, any number above 10 products in stock is not relevant.
Now, when it comes to reporting, you need to create a calculated metric:
event1/event2. This calculated metric will show the average of items in stock for each product. Using
event3 in the reports, you will get the number of times each product was shown and it was out of stock.