If you use a Google Tag Manager variable whose type is “number” to send data to Google Analytics, you may notice that some of your data comes through as (not set), rather than the value you wanted.
The example above shows an event label which is pulled in from the score on a quiz with 5 questions. This is pulled when the quiz is completed. There is one score missing – 0.
Using Google Tag Manager debugger, I can tell that the variable fires from the data layer as 0. It doesn’t appear as (not set) or undefined.
Above: score – Data Layer Variable – number – 0
As well as this, if I look at the event firing, the label it is pulling in is 0.
Above: Label – 0
From this information, it seems that the event label in Google Analytics will be 0. However, along the way 0 is transformed to (not set). This is not the first time I’ve noticed Google Tag Manager debugger reading unreliably.
TIP: When debugging, make sure to check the real-time data in Google Analytics after your tag is live, to ensure the data appears as expected.
I managed to rewrite (not set) to 0 by creating a new look-up table variable which maps 0 to itself. Because all the other scores were working I set the default value as the original score, so they would remain unchanged. I then used this new variable as the label for the event tag.
What this new variable does is transform 0 from a number to a string. For some reason Google Analytics parses the number 0 as (not set) but the string ‘0’ as 0.
Reviewing what Google Tag Manager Debugger shows you can see the slight difference in using score (number) and score string (string) as a variable.
In Google Analytics we can now read the event label as 0 instead of (not set).