#GTMtips: Undefined Dimensions Won't Get Sent
This might not sound like a tip to you. You might think, “Dimensions won’t get sent? Sounds like a bug!”. You’re wrong. This is one of the awesome features of the GA API, and it’s key to making your tag setups leaner when sending data to Google Analytics.
Tip 4: Undefined dimensions are left out of GA hits
Note that ‘undefined’ here means the special value
The hit itself will get sent, but the dimension will just be dropped out.
How is this awesome? Well, you might have thought until now that you need two tags for each version of the dimension reference: one for when it has a value, and one when its value is
undefined. The latter version doesn’t have the dimension field populated at all.
You don’t have to go through this duplication of tags if you learn to use the power of
undefined in your GTM macros. Just make sure the value is really
undefined and not
'undefined', which is a String.
It’s not just Custom Dimensions this works with. Any fields that are translated into dimensions behave the same way, meaning you can use this to send pretty darn efficient virtual pageviews as well, as they use the Document Path field in your tags.