Nov 5, 2023

Custom Event named as an Automatic Event will duplicate events in GA4

Some days ago I found a question on Reddit asking what happens when Custom Event and GTM GA4 Event have the same event_name? I wanted to be 100% sure about the answer so I decided to do a pretty simple test I will show in the next lines.

The most complete guide I’ve found about duplicate events in Google Analytics 4 is of course something by Julius:

Unfortunately, that wasn’t enough for what I wanted to prove, so I hope I can help someone sharing how I tested it, precisely tackling the question.

How I set GTM to duplicate an automatic event

First things first, I set a GA4 event tag on Google Tag Manager replicating an automatic event. I’ve chosen the GA4 event page_view, but it could have been anything else.

Triggers were exactly the same to be sure they fired at the same time (see snapshot below).

The Google Tag - sending a page_view - and the parallel custom GA4 page_view event I set](  The Google Tag - sending a page_view - and the parallel custom GA4 page_view event I set
The Google Tag - sending a page_view - and the parallel custom GA4 page_view event I set

The GA4 event tag was set by adding just a custom parameter to let me easily recognize what I was looking at in the DebugView.

The GA4 event tag is set with a custom parameter foo with value bar
The GA4 event tag is set with a custom parameter foo with value bar

Results: Will both automatic and custom GA4 events fire?

I haven’t published my new version of the GTM container but simply used the Google Tag Assistant to test the results in the GA4 DebugView.

The results were straightforward. Both the automatic page_view and the custom page_view were fired. The first page_view event was the automatic one while the second contained the custom parameter foo.

page_view automatic event automatically created by GA4
page_view automatic event automatically created by GA4

page_view custom event with custom parameter foo
page_view custom event with custom parameter foo

Here we go, a complete test to successfully prove what happens when automatic events get duplicated with custom ones. There’s no deduplication on Google’s side, so look out!

Aug 4, 2023

How to convert the Google Tag Manager JSON to a spreadsheet overcoming Excel limits with KNIME

Most of the time you can easily convert a Google Tag Manager JSON file to an Excel one with some free tools.

The best tool of this kind is probably the Google Sheets extension “GTM Tools” by the almighty Simo Ahava.

Unfortunately, the free superpowers of this add-on can encounter some bitter moments where things go wrong, as well as any other tool.

The issue with Google Sheets characters limit in a single cell

I was trying to wrap my head around a GTM setup so I decided to use GTM Tools to simplify the overview of tags and triggers.

During the processing phase of the GTM container assessed, I got a strange error message breaking the workflow.

The error message raised by GTM Tools Google Sheets extension

The issue is that one of the tags was more than 50k characters long - I know that sounds crazy - which is the maximum limit of chars available in Google Sheets!

KNIME to the rescue… maybe

I’ve used KNIME in the past to automate some tasks. One of the most interesting stuff I published in KNIME Hub was a simple workflow taking a GTM JSON file and converting it to an Excel one.

I must be honest, I’ve usually preferred GTM Tools since it’s a bit more hassle-free, a couple of clicks and you’re there. In this case, I thought my little KNIME application using Excel instead of Google Sheets could have made my day.

Unfortunately that was not the case since Microsoft Excel has got its own limit of 32k characters which is even less than the Google Sheets one!

The error message raised by the KNIME Excel Writer node 😟

How I made it work

The easiest way I found to make it work, was to edit the KNIME application looking for a way to split into multiple columns the cell content related to the infamous tag, before the Excel Writer node was run.

Here below is how the workflow appears after adding a couple more KNIME nodes: The Cell Splitter By Position node - in charge of splitting the content - and the Column Filter node - used to remove the original column with the extra large content to split.

The final KNIME workflow with the Cell Splitter By Position and the Column Filter nodes in the 3rd branch

In particular, to make it work, I set 4 split indices to split the content when it reaches 30k, 60k, 90k or 120k characters.

For each split the node will create a new column. The original column coming from the GTM JSON was named Details so I decided to just name them Details1, Details2 and so on, Details5 being the last one at the 4th split.

Configuration of the Cell Splitter By Position node

The table previews generated by KNIME are quite straightforward about the results of the node.

The table preview before applying the Cell Splitter By Position node
The table preview after applying the Cell Splitter By Position node (we will remove the original Details column with the next node)

And that worked like a charm. Now my GTM JSON file perfectly fits a simple Excel file!

Feb 21, 2023

Summary of Google Analytics 4 Certification program on Google Skillshop

This post comes from the notes I wrote down before taking the Google Analytics 4 Certification. 

To be honest I think this time the Google Analytics material is way too long and verbose than how it was in the Google Analytics Academy for the previous certification.

I believe this post is a bit too long as well, however it could be helpful for those who want to take the Google Analytics 4 Certification and would like a summary of the material provided by Google on its Skillshop website. This is the reason why I'm sharing it here exactly as I wrote it for me.

I strongly recommend copy/pasting this summary in a Google Docs/Microsoft Word file and use the headings to reshape the text structure as desired.



Jan 26, 2023

How to tie sessions to transactions tracked via Measurement Protocol for GA4

Today, I'm going to show a simple yet powerful experiment I've made with Google Analytics Measurement Protocol. 

I was looking for ways to do this test with Python or R but the Google Analytics 4 Event Builder proved to be more than enough. 

Where it all started

I'm working with a client who needs sending purchase events to Google Analytics through Measurement Protocol (long story short). 

After a first implementation we've found everything was correct but purchase events were not tied to any information about the channel driving them.  

Transactions are coming from Unassigned

God bless Measure Slack

There are no words to describe how Measure Slack helps with these issues: It's awesome! 

In this particular case I wasn't actively looking for an answer to my problem but, all of a sudden, I've found one person with the same exact issue I had, WOW.

The first reply to his question was the answer to my issue!

First reply in Measure Slack pointing towards Google documentation

As a matter of fact, in its documentation at this link, Google recommends:
In order for user activity to display in standard reports like Realtime, engagement_time_msec and session_id must be supplied as part of the params for an event.

Time to test with the GA4 Event Builder

I trust people in Measure Slack but I needed to test things out to be sure there were no drawbacks and to be confident passing this information to the developer team. 

My plan was to send events through the Event Builder with and without the engagement_time_msec and session_id parameters to see what could happen. 

Here follows an example payload I've made using the GA4 Event Builder (with those two parameters populated): 

An example payload with engagement_time_msec and session_id parameters

To populate those fields two things to keep in mind:
  1. engagement_time_msec can be anything so I decided to put a simple 1 in there (UPDATE: Simo actually tested and reported in the same Slack thread that this parameter is probably not needed at all)
  2. session_id should instead be something real so I had to take this information from a debugging session with Google Analytics Debugger, the Chrome extension available here.
Where to find the session_id in Google Analytics DebugView


I tested all the transactions have been sent to GA4 with a simple check on the Real Time report 

transaction_ids tracked in  the Real Time report

Then I waited some hours to dive deeper on the transactions tracked. The next day I've found sessionization have worked astonishingly well.

Session default channel groups with right attribution of transactions

I've actually sent 3 purchase events without engagement_time_msec and session_id and just one with both of them. 

Indeed, 3 purchase events were not sessionized so got attributed to Unassigned, the one with both additional parameters was associated to Direct correctly.