One of the first things you do in GA4 after installing a base tag with a page_view
in it, is probably adding a new event, or adding an event parameter to an event.
In this post, I will show you how to make sense of Event Parameters.
- What is an event parameter
- How to add them (using GTM) to an event
- How to find them in the GA4 interface
- Common mistakes, annoyances and pitfalls
- How to extract them from Big Query – some recipes
What is an event parameter
No better source than the Google documentation for the definition: Parameters are additional pieces of metadata that add context to event data.
Think of them like Event Category / Action / Label on steroids. You can add up to 25 event parameters on any event.
They come in various flavors:
- event scoped: these are called event parameters
- user scoped: these are called user properties
As you can read in the docs, some parameters are sent automatically (the document mentions page_title
as an example).
Now.. that page_title example is a good example of “not all things are like they appear”. Page Titles are handled in a special way by the tracker.
For now, remember this:
Some event names and parameter names combinations are special. Don’t use them, unless you know what you’re doing.
— me
Special event parameters
Unexpected things may happen when you use a parameter name that are
- configuration parameters (like:
cookie_flags
,event_callback
, etc ) - reserved names (like
items
) - special in an other way (like
client_id
,page_title
,page_referrer
, etc)
There is no exhaustive list, to my knowledge. Start at the API reference to find special names.
How to add parameters to an event – in GTM
The Direct way
If you have information available in the dataLayer, and have a trigger, then it’s really easy to create an event tag (like below, download_whitepaper
– and add all the meta-info that is relevant to this event.
As you can see, most information comes from variables. I also set a user property “whitepaper_reader” to “yes”, so when the user comes back, GA4 remembers it (more on that later).
Via the Configuration Tag
There’s also an other way to add event parameters, and that is via the Config Tag.
In the configuration tag, the “Event Parameters” block is called “Field Names”. See below.
The field names can be configuration settings (the “special” parameters), but can also be plain ol’ event parameters.
In the case above:
- content_group is a parameter (that has its own built in dimension in GA4, so semi-special)
- cookie_name and transport_url are configuration directives (send via this endpoint)
- clean_path is a proper event parameter
- wordpress_role is a user property
The config tag is special..
Yes.. the config tag is special. In the following ways:
All tags that use the Configuration Tag “inherit” the settings AND event parameters + user properties that are in the config tag.
So.. All my event tags will have “content_group” set.
But beware.. the configuration tag is evaluated only once.
This means: if the configuration tag fires, the dataLayer variables that are current on that moment will be used. So if {{DL - visitorType}}
changes at some point (via a new dataLayer push), all events on the page will still reflect the old value.
So:
- use config tag field name / values only with values that exist in the dataLayer at the moment of firing
- if those datalayer values change, you need to override them (via “the direct way“)
How to find Event Parameters in the GA4 interface
If you configure nothing in GA4, the event parameters you send are still visible in the interface.
In the realtime section, there is a widget “event count by event name“. If you click an event name, all parameters that are sent, are visible.
If you click again, the event parameter values can be seen.
How to use them in GA4 reports
To actually use them in reports, there’s two ways
- special event parameters (like content_group ) are available as-is.
- custom event parameters you need to register as custom dimension or metric
Example: the “clean_page” parameter (in the example above “clean_path”, different property, sorry) is configured as Custom Definition here, called “Clean Page Name”.
When you do that, you can use that dimension in the report drilldowns and in the explorer.
But beware.. the custom dimensions are not filled in retroactively! They are only available after the registration date.
Common mistakes, annoyances and pitfalls
Here’s some things to note when sending event parameters.
Limits
Yes, there are limits to event parameters. See the official documentation for all details. Here are the most common ones:
- there is is 100 character event parameter value limit – you cannot send JSON blobs, or User Agent strings anymore – thos will be truncated.
- there is a 36 character limit when using a user parameter
- exactly the length of a UUID string
- too short to store a SHA256 hash (64 chars)
- too short to store a SHA1 hash (40 chars)
- you can send 25 event parameters per event (If you have the GA4 free version)
Especially the last one is tricky:
Let’s say your configuration tags sets 15 parameters. Then your events can only have 10 parameters. If you accidentally send 15 + 15 and the total will be 30 and 5 will be dropped .
Thanks to some helpful input (Thanks Todd and Simo!) – I learned that the event parameters are processed in alphabetical order. So if you send too much, the ones earliest in the alphabet will be kept.
Dimension or Metric.. choose wisely
When you send string values (“whitepaper_name”) it’s no choice: that will be a Dimension.
When you send obivous numbers (“price”, or “page_load_time_in_ms”), it’s easy too: that is a metric.
But.. how about information that is numeric, like “items_in_cart”, or “number_of_tries”? Sometimes you want to use that parameter as a metric (avg number of tries), but sometimes as a dimension (drill down by number of items in cart).
In GA4, you are forced to choose. If you want them both? You will need to send 2 seperate event parameters.
Conversion events only look at event names, not parameters
If you create your implementation plan, and you want to mark certain events as conversion.. well.. choose your event names wisely.
For example if you tag your site like this:
- event name: submit_form
- parameter: form_type = “Support request” or “Lead form”
Then it’s not possible to mark “Submit a Lead Form” as conversion. You can only mark “submit_form” as conversion.
You will have to work around this, and you can do so in 3 ways:
- create a new event in GTM with a new name
- create a new event in the GA4 configuration (see screenshot)
- create an audience using the event_name and parameter value combination, and select an audience trigger (see second screenshot)
After this, you can mark your new event as conversion just fine
How to extract the from Big Query – some recipes
When you have enabled Big Query exporting of your events, you can access ALL event parameters immediately – no need to pre-register them.
They can be found in the event_params
column. This column is a nested record and contains one “key” column, and several value columns, depending on the parameter type (string, int, double, float).
Here’s some recipes to get the values:
Single string value extraction
In order to extract a single string value, use this SQL sub-select:
SELECT event_date, -- for numeric values, use int_value, or float_value instead (select value.string_value from unnest(event_params) where key = 'content_group') as content_group, count(*) as events FROM `stuifbergen.analytics_225721399.events_20220123` group by 1,2
Find out if it’s a sring, int or float
Big Query decides on how the value looks what value column to use.
- a value like “hello” will always be a string
- a value like “42” will be stored as INT
- a value like “3.14” will be stored as double
Now.. Sometimes you have mixed results. “Price” for example can sometimes be an INT, sometimes a FLOAT. To catch all, you will need to fetch both value columns, and use coalesce
and cast
to convert the values to 1 format.
That’s SQL.. lots of typing.
Here’s a snippet that counts how often each column is filled for 1 particular parameter, and also shows you 5 sample values.
-- enter parameter key here: declare k STRING default 'selected_size'; -- date range to check declare start_date STRING default '20220110'; declare end_date STRING default '20220111'; with check as ( select k as parameter_key, array_length(array_agg((select value.string_value from unnest(event_params) where key = k) ignore nulls)) as str_freq, array_agg(cast((select value.string_value from unnest(event_params) where key = k) as STRING) ignore nulls limit 5) as str_sample, array_length(array_agg((select value.int_value from unnest(event_params) where key = k) ignore nulls)) as int_freq, array_agg(cast((select value.int_value from unnest(event_params) where key = k) as STRING) ignore nulls limit 5) as int_sample, array_length(array_agg((select value.double_value from unnest(event_params) where key = k) ignore nulls)) as dbl_freq, array_agg(cast((select value.double_value from unnest(event_params) where key = k) as STRING) ignore nulls limit 5) as dbl_sample, array_length(array_agg((select value.float_value from unnest(event_params) where key = k) ignore nulls)) as flt_freq, array_agg(cast((select value.float_value from unnest(event_params) where key = k) as STRING) ignore nulls limit 5) as flt_sample, from `you-project.analytics_24549999.events_*` where _table_suffix between start_date and end_date group by 1 ) select parameter_key, "string" as parameter_type, str_freq as frequency,array_to_string(str_sample, '\n') as sample from check union all select parameter_key, "integer" as parameter_type, int_freq as frequency,array_to_string(int_sample, '\n') as sample from check union all select parameter_key, "double" as parameter_type, dbl_freq as frequency,array_to_string(dbl_sample, '\n') as sample from check union all select parameter_key, "float" as parameter_type, flt_freq as frequency,array_to_string(flt_sample, '\n') as sample from check
The output will look like this:
voila!
That’s it (for now)
Do you know how to make sense of event parameters in GA4 now? I hope so!
If you have anything to ask, drop me a line! Happy tagging!
Tom says
Hi Jules,
Really useful article, thank you! :)
You wrote that “the configuration tag is evaluated only once.
This means: if the configuration tag fires, the dataLayer variables that are current on that moment will be used. So if {{DL – visitorType}} changes at some point (via a new dataLayer push), all events on the page will still reflect the old value.”
What does “once” exactly mean? Once par page load (page_view event) or once for the whole session?
Thank you,
Tom
jules says
Once per page load
Ani says
Hello Jules, if I want to send a user property (let’s say – email) then is md5 encryption enough? All other encryption methods will be too long.
jules says
md5 will fit, so yes you can use it. But don’t call it encryption – it’s just a hash.
Tim Leighton-Boyce says
The 100 character limit for parameter values seems very short. I can think of far more mundane data than JSON blobs which will be affected, for example complex URLs on custom external link tracking.
I wonder if there is any chance of some of these limits being increased? Or can you suggest work rounds? For example, in the external URL perhaps we could split it into domain and path parameters. But what a waste.
Yoglica says
Hi Jules,
Nice blog post and informative one. I was checking for GA4 event setups and found this.
Thanks
Sudheer Kota says
Hi Jules, We are migrating from GA Universal to GA4. Created some custom events with parameters. We wanted to extract these custom event parameter names and values from Data API( for GA4) for our internal reporting purpose but could not succeed using the predefined Dimensions. After going through your blog, I understand that the only way to get the event parameter details are using the BigQuery. Is my understanding correct or do we have any other way to get these details using runReport by using some dimension name ?
jules says
Hi Sudheer,
Two options:
1. use Big Query – alle event parameters on every hit (up to 25 per event) are stored there
2. register them as custom dimension or metric
If you choose the 2nd, they are available in the API, in Looker Studio, and via the API – from the next day onwards.
It’s mentioned in the article btw (a bit hidden, I’ll give you that :-) )
Clauds says
Hi, I have a question and hope you will help me.
We have Single web page apliaction, so config tag is evaluated only once and then we have virtual page_views events.
My problem is that, when user is not looged-in, we do not have user_id so we are not able to send it. When user is finally loged, then we send “Log_in” event with user_property: “user_id” because at this moment we have it. My issue is the user_id is set only for that event log_in but after that all page_views all the other events do not have filled user_id only log_in event.
We work in big query, so i see user_id only with log-in event.
jules says
You can use either the “new style” configation (gtag, with event parameters that are reflecting the _current_ value), or just include the user_id parameter to the page_view tag.
Claud says
Hi, thank you for quick answer :)
I tried to add user property “user_id” to the page_view event and with that event I can see the user_id but the problem still persists with other events. It still inherits the undefined value from config tag. Should i send user id with every single event and add the user_id as user_property to the every single event?
jules says
Yes :)
Or use the new Google Tag config in GTM.
See here: https://youtu.be/1POi1BZxXwg?si=wa05fBT5bFOUJm3D
or read here: https://www.simoahava.com/analytics/google-tag-template-in-google-tag-manager/