Search code examples
google-analytics-apigoogle-analytics-4

Generate a report on GA4 using Data Layer Variables


I want to be able to generate a report based on a Data Layer Variable that is sent to Google Analytics 4. For simplicitys sake, assume i send in a BookID to GA:

dataLayer.push({
    'book_id': <%= BookID %>
});

In Google Tag Manager Variables, I've also set up an Event Settings as well as a Data Layer Variable GTM Variables Section

In the Data Layer Variable configuration, it is referenced to the ID Event Settings Data Layer Variable config

And in the Event Settings, it is referenced in the MY_APP Tag. Event settings config

And when i preview this using the debugger, it shows up no problem: Debug view with variables

What im trying to achieve: Before Google did their update, I was using the API to basically bring me stats for how many people have visited the page for a specific Book. Now after the update, I just want to be able to generate a simple report and be able to use Book_ID as a metric. For example, to see which book has the most page views.


Solution

  • What was missing was a GA4 event tag