Member-only story
Gauging demand for out-of-stock products with Shopify and GA
Knowing what products people want to buy is one of the biggest problems in retailing. So how do you find out what your customers want?
There are several ways: Listening to customer queries, looking at site search logs for phrase without results, Google Trends and monitoring what sells for competitors.
Another method is looking at how many page views sold out products in your catalog are getting, which is the one I’m going to talk about today.
Sometimes this can either help you know whether or not to re-stock a specific product that has just sold out. Other times you can look a bit wider at the number of page views for a collection of product that might be the same colour or product type.
Collecting the data
So lets use that old favourite Google Analytics and specifically the Event Tracking. So in the product.liquid template of Shopify, we’ll drop a little JavaScript to pass an event to GA, then wrap it in a liquid tag to only display the script when the product is unavailable (sold out).
{%- unless product.available -%}
<script>
try {
ga('send', 'event', 'OutOfStockHit', {{ product.vendor | json }}, {{ product.title | json }}, { nonInteraction: true });
} catch (e) {}
</script>
{%- endunless -%}
You’ll notice that the eventCategory is “OutOfStockHit”, then we are using the Vendor as the Action and Product title as the Label. These should…