Back to all articles

The product list performance in Google Analytics: improved reliability through actual product impressions

Willem Blom
Willem Blom
Impact investor & Global SVP Growth – DEPT®
Length
10 min read
Date
1 April 2021

Line 2 sets the variable DLV – Ecommerce – Impressions. Line 3 sets the variable count (the counter of the products) to 0 if the value is undefined. The variable count turns to 1 the first time the tag fires (line 4). It grows by one unit each time the tag fires again, that is each time a new product appears on the screen. Line 5 sets the condition for the dataLayer push. If the variable count – (count/1) gives no remainder (so it is equal to 0), then the event impressionsPushed is pushed to the dataLayer. Since any number divided by 1 always equals that number, the remainder will always be equal to 0 so the dataLayer event and the impression details will be pushed for each single (and visible) product on screen.

At this point, I think it is important to highlight that through this solution one single Google Analytics event for each product is sent. To limit the number of hits to Google Analytics and avoiding the risk of exceeding the quota limit of the free version, we could also group the products in clusters. Groups of 4 or 6 products could be a good trade-off as usually they are listed in rows of 2 or 3 on mobiles’ and desktops’ screens. An improved version of the previous JavaScript code, considering grouped impressions of 6 products, is displayed below.

If a bigger or smaller cluster is needed all the 6s in the script need to be replaced. From line 12 to 20 we needed to consider the quite common case that the total number of products in the page is not a multiple of the chosen product cluster number. Say that in our client’s page we had 50 products, the last 6-group would be sent at the 48th product on the page. Despite being shown in the screen products at positions 49th and 50th would not been sent unless they are collected by the remainder variable at line 13 and subsequent push at lines 14-17.

In both scripts, lines 8 and 9 slice the e-commerce object and fetch only the product details of the equivalent product displayed. For our case we opted for the second version. We named the tag HTML – Impressions on category pages and associated it to the trigger Element visibility – Product selector.

Event to send the product impressions

The last phase was to collect the sliced bits of dataLayer and send them to Google Analytics. We created a Google Analytics event tag triggered by the custom events pushed by the HTML tag.

  • Track Type: Event
  • Event category: Enhanced Ecommerce
  • Event action: {{Event}}
  • (optional) Event label: {{Product name}}
  • Analytics settings: Google Analytics global variable (EEC features enabled)
  • Trigger: CE – Impressions pushed
    Custom event type, impressionsPushed thrown by the HTML tag
  • Name of the tag: UA – EEC – Impressions on category page

Implementation checklist

To test our implementation we inspected several factors in the Google Tag Manager preview window. On the category page of the website we verified that:

  • The UA – Pageview – category pages only (having EEC features disabled) tag fired
  • The UA – Pageview – all pages NO category pages tag did not fire
  • For each product seen on the screen (or 6-groups of products), there was a chain of events named elementVisibility and impressionsPushed in the events list of the preview window
  • When inspecting the dataLayer at a given impressionsPushed event, the product list position and the event number of the dataLayer push matched

Through the Chrome Network tab we also inspected the event hit and verified that Ecommerce was set for the Event Category and Impressions for the Event Label. Furthermore, of course, the hit also displayed the EEC impressions details for a single product e.g. il1nm: category page (list name); il1pi1nm: kid t-shirt (first product name), il1pi1id: 0123 (first product id), etc.

No more dropped hits and reliable data at once

The actual product impressions solution allows us to address two not uncommon issues: it generates lighter hit payloads which never exceed the size limit and it remarkably improves the reliability of the Product List Performance report in Google Analytics. The two main components of our solution are represented by the handy element visibility trigger type available in Google Tag Manager, able to pinpoint each product shown on the screen, and the custom javascript code which slices the entire dataLayer into smaller units. I wish to thank my colleague Jasper Jansen for his huge contribution in this implementation.

More Insights?

View all Insights

Questions?