This article explains how you can implement Universal Analytics property events as Google Analytics 4 (GA4) events.
To populate UA and GA4 properties at the same time, include both the tags for your UA property and your GA4 property.
The basic page tag is required in order for event tags to function.
Universal Analytics vs Google Analytics 4 events
In Universal Analytics (UA) properties, an event is a special kind of hit (distinct from, for example, a pageview) that has a Category, Action, and Label. By contrast, in Google Analytics 4 (GA4) properties, everything (including a pageview) is an event. GA4 events have no notion of Category, Action, and Label and, unlike in UA properties, GA4 reports do not display Category, Action, and Label. Therefore, it’s better to rethink your data collection in terms of the GA4 model rather than port your existing event structure to GA4.
GA4 events can be:
- automatically-collected events
- Enhanced Measurement events - automatically collected, but enabled in the GA4 UI
- Manually-instrumented events via code on your page or via an event instrumented in Google Tag Manager
Finding an equivalent GA4 event
If you want to translate a UA event to GA4:
- First, look for a matching automatically-collected event. If you find a matching event, you should not recreate a new event. If no matching automatically-collected event exists, proceed to step 2.
- Look for matching Enhanced Measurement event. If you find a matching event, you should not recreate a new event.
- Look for a matching recommended event. Implement your tagging to trigger the recommended event.
- Finally, if you cannot find a suitable equivalent event, create your own custom event.
Example: Enhanced Measurement event
If you use a Universal Analytics (UA) event to measure outbound clicks, you would not create a custom event because this behavior is already available as an Enhanced Measurement event. Similarly, if you use a UA event to measure file downloads, you would use the "File downloads (file_download)" Enhanced Measurement event instead.
You may find an Enhanced Measurement event that is equivalent to your UA event,
but that doesn’t support all the parameters you need. For example, let’s say
that you want to use the file_download
event, but need to add a file size
parameter. To do this, first disable "File downloads" in Enhanced Measurement,
then manually send the file_download
event with your own parameters:
gtag('event', 'file_download', {
file_extension: '.mp4',
file_name: 'tutorial.mp4',
link_url: '/videos/tutorial.mp4',
link_text: 'Download the tutorial here!'
// Custom parameter
file_size: '275 MB'
})
Example: Universal Analytics event with no Google Analytics 4 equivalent
Imagine that you send the following custom event in analytics.js:
ga('send', 'event', 'myCustomEvent', 'myEventAction1', 'myEventLabel1');
or, using a slightly different syntax:
ga('send', {
hitType: 'event',
eventCategory: 'myCustomEvent',
eventAction: 'myEventAction1',
eventLabel: 'myEventLabel1'
});
Since myCustomEvent
does not correspond to an automatic, Enhanced Measurement,
or recommended event, you would trigger it as follows in gtag.js:
gtag('event', 'myCustomEvent', {
"TheEventAction": "myEventAction1",
"TheEventLabel" : "myEventLabel1"
});
Since TheEventAction
and TheEventLabel
are custom event parameters, you’ll
need to register them in order to see them in reports.
If you currently use gtag.js
If you currently tag for a Universal Analytics (UA) property using gtag.js and trigger an event as shown in the code sample above, the event will be automatically be sent to your Google Analytics 4 (GA4) property as well, provided that:
- You have added your GA4 measurement ID to the basic gtag.js snippet
- The event doesn't have an explicit
send_to
parameter assigned
You should review all of the event code on the page to ensure that you indeed want to send all the gtag.js events to the all the gtag.js containers on the page. If so, you can leave these events alone. Otherwise, add a "send_to" parameter to control which property or product (e.g. Google Ads) the event should be sent to.
If you use Google Tag Manager
To do the same in Google Tag Manager, you will create an Google Analytics 4 (GA4) Event tag:
- Click Tags > New.
- Click Tag Configuration and select Google Analytics: GA4 Event.
- For Configuration Tag, select your GA4 Configuration tag from the menu.
- For Event Name, enter
myCustomEvent
. Expand the Event Parameters section and add two rows with the following Parameter Name and Value entries:
Parameter Name Value TheEventAction
myEventAction1
TheEventLabel
myEventLabel1
Click Triggering and select an appropriate event that will fire the tag.
Save the tag with an appropriate name (e.g. GA4 event – click – add to cart), and publish your container.
Comparison of Universal Analytics vs Google Analytics 4 reporting
In your Universal Analytics (UA) property, myCustomEvent
will be reported in the Behavior >
Events > Top Events report. The report breaks out your UA events by Category
and Action.
In your Google Analytics 4 property, myCustomEvent
is reported alongside all other
events.
Here is myCustomEvent
as reported in the Realtime report:
Here is myCustomEvent
as reported in the Behavior report.