This article is part of the Universal Analytics to Google Analytics 4 migration guide. See the migration guide table of contents.

[UA→GA4] Send analytics.js event, timing, and exception hits to Google Analytics 4

A Google Analytics 4 setting lets you collect analytics.js hits as events in your Google Analytics 4 property

If you collect data for a Universal Analytics property and a Google Analytics 4 property (via dual tagging with analytics.js and gtag.js), you can use a single setting in your Google Analytics 4 property to automatically capture the following Universal Analytics hits:

  • Event hits (i.e. Category/Action/Label events that you collect using analytics.js)
  • Timing (load-time events)
  • Exceptions
This feature does not support Custom Dimensions and Metrics, Enhanced Ecommerce data, or User-ID. If you rely on these capabilities in your Universal Analytics property, we recommend updating your instrumentation in gtag.js or Google Tag Manager to log the necessary Google Analytics 4 fields.

While this setting lets you easily capture these three hit types as events, our recommended best practice is to update your code to capture that behavior using the Google Analytics 4 data model. Learn more

See related event information in Google Analytics 4

The following table lists the event information you see in Google Analytics 4 for each of the Universal Analytics hit types.

Universal Analytics hit type What you will see in your Google Analytics 4 property

Event

Collected via:

ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

Example:

ga('send', {
  hitType: 'event',
  eventCategory: 'Videos',
  eventAction: 'play',
  eventLabel: 'Fall Campaign',
  value: 60
});

Learn more

// ga('send', 'event')
eventName = fieldsObject['eventAction'];
'eventCategory' -> 'event_category'
'eventLabel' -> 'event_label'
'eventValue' -> 'value'

Example:

Event name: 'play'

Event parameters:

  • event_category = 'Videos'
  • event_label = 'Fall Campaign'
  • value = 60

Timing

Collected via:

ga('send', 'timing', [timingCategory], [timingVar], [timingValue], [timingLabel], [fieldsObject]);

Example:

ga('send', {
  hitType: 'timing',
  timingCategory: 'JS Dependencies',  
  timingVar: 'load',
  timingLabel: 'new platform',
  timingValue: 3549
});

Learn more

// ga('send', 'timing')
eventName = 'timing_complete';
'timingCategory' -> 'event_category'
'timingVar' -> 'name'
'timingValue' -> 'value'
'timingLabel' -> 'event_label'

Example:

Event name: timing_complete

Event parameters:

  • event_category = 'JS Dependencies'
  • event_label = 'new platform
  • name = 'load'
  • value = 3549

Exception

Collected via:

 ga(‘send’, ‘exception’,, [fieldsObject])

Example:

ga('send', 'exception', {
'exDescription': err.message,
'exFatal': false
});

Learn more

// ga('send', 'exception')
eventName = 'exception';
'exDescription' -> 'description'
'exFatal' -> 'fatal'

Example: 

Event name: exception

Event parameters:

  • description = err.message
  • fatal = false

 

Set the option in Google Analytics 4

You should set the following option as soon as you create your Google Analytics 4 property.

  1. Click Admin.
  2. At the top of the Property column, use the dropdown selector to select the property you want.
  3. In the Property column, click Data Streams, then click the relevant web data stream.
  4. Under Additional Settings, click More Tagging Settings.
  5. Under Event Settings, turn on the switch for Collect Universal Analytics events.

 

Was this helpful?
How can we improve it?
Search
Clear search
Close search
Google apps
Main menu
Search Help Center
true
69256
false