How to instrument Universal Analytics events as Google Analytics 4 events

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:

Finding an equivalent GA4 event

If you want to translate a UA event to GA4:

  1. 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.
  2. Look for matching Enhanced Measurement event. If you find a matching event, you should not recreate a new event.
  3. Look for a matching recommended event. Implement your tagging to trigger the recommended event.
  4. 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:

  1. You have added your GA4 measurement ID to the basic gtag.js snippet
  2. 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:

  1. Click Tags > New.
  2. Click Tag Configuration and select Google Analytics: GA4 Event.
  3. For Configuration Tag, select your GA4 Configuration tag from the menu.
  4. For Event Name, enter myCustomEvent.
  5. Expand the Event Parameters section and add two rows with the following Parameter Name and Value entries:

    Parameter Name Value
    TheEventAction myEventAction1
    TheEventLabel myEventLabel1
  6. Click Triggering and select an appropriate event that will fire the tag.

  7. 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.

View of top events showing custom event categories and actions

In your Google Analytics 4 property, myCustomEvent is reported alongside all other events.

Here is myCustomEvent as reported in the Realtime report:

Results of realtime report showing myCustomEvent and myEventAction1 and
myEventAction2 in results

Here is myCustomEvent as reported in the Behavior report.

View of behavior report shoiwng myCustomEvent listed