Tracking Out of Stock Products in Google Analytics

A step-by-step guide with Google Analytics & Google Tag Manager

SHARE THIS         

Steve Lamar - PromoPrep Founder

by Steve Lamar

One of the worst customer experiences you can create is sending a customer to a product page with out of stock products. Not only is this bad for your customers, it is a waste of marketing budget.

In this article, I walk you through how to create a report in Google Analytics using Google Tag Manager showing out of stock products by channel. You’ll know exactly what products are getting pageviews and what channels are sending traffic to these pages.

Bonus: If you want to download the json container to import the variables, trigger and tags into Google Tag Manager described in this article, you can download it here.

After following the steps in this article, you’ll have a report in Google Analytics that shows you exactly what channels are sending traffic to out of stock products:

 What you’ll need to implement:

  1. Google Analytics & Google Tag Manager implemented on your website
  2. Basic knowledge of how Google Tag Manager works 

To get started, identify pages on your site that have out of stock products. We’ll be using Backcountry.com as an example.

They have a clear message on product pages when they are out of stock, making it easy to create rules in Google Tag Manager to identify these types of pages:

Google Tag Manger Setup

In Google Tag Manager, create one tag, one trigger and three variables.

Variable Creation

Let’s start with the variables.

Variable 1 : DL – Product ID

Create a variable to capture the product ID that will be used in the event label. Backcountry has a dataLayer element for product ID when the product page loads:

Setup a Data Layer variable in GTM:

Variable 2: DL – Product Name

Capture the product name to pass to Google Analytics like this:

Variable 3 : DOM – H3

Finally, create a variable to identify the page with ‘out of stock products’. In Backcountry’s case they use an H3 with the text ‘Temporarily out of stock’:

This variable will be different for your site depending on how the out of stock message is displayed.

Add a new DOM Element variable and setup the CSS Selector based on your specific parameters. In this case, we are setting it to h3:

Trigger Setup

Now that the Variables are setup, let’s create the trigger that will fire the tag.

Backcountry has an event that is pushed to the datalayer called ‘productView’. Your site may have something different depending on the setup. But, find the event that contains the ecommerce product data like this:

Once you know what event is firing to update the dataLayer with the product details, create a Custom Event trigger.

In Event Name, put the event that is used in the dataLayer – in this care productView.

Then select ‘Some Custom Events’ and select the DOM variable you setup to capture the ‘out of stock’ message.

Then enter the on-page text used to designate the pages as being ‘out of stock’ – in this case, it is ‘Temporarily Out of Stock”:

Tag Setup to Push Event to Google Analytics

Now you have everything need to create the tag that will will push the data into Google Analytics.

Add a new tag with the following parameters:

  1. Tag Type: Google Analytics: Universal Analytics
  2. Track Type: Event
  3. Category : ecommerce
  4. Action : product view – out of stock
  5. Label : {{DL – Product ID}} | {{DL – Product Name}}
  6. Non-Interactive Hit = TRUE
  7. Trigger : CA – productView – Temporarily out of Stock

 

Test and publish your changes!

Create Report in Google Analytics

Now to set up a report in Google Analytics go to Customization > Custom Reports

Select Flat Table as the report type.

Add Default Channel Grouping and Event Label as dimensions and Pageviews as metrics.

In filters, select Event Action and enter “product view – out of stock” and save the report.

You can now see every channel that is sending traffic to out of stock products and the products that are being views. Then work with your channel leads to get the channels fixed to stop the traffic flow.

Bonus: If you want to download the json container to import the variables, trigger and tags into Google Tag Manger, you can download it here.

Looking for a better way to manage your marketing calendar? PromoPrep can help.  Learn More