Customer data & Analytics
Google Analytics
Uniform enables you to add personalization and testing capabilities to your applications. Google Analytics is a popular product for capturing and reporting on activity in your application. Uniform is able to push personalization and testing data to Google Analytics, improving the reach of your analytics.
info
This analytics integration in Uniform is for GA4. The previous generation product, (Universal Analytics), is being deprecated by 1st July 2023. You can learn more about Universal Analytics and its corresponding Uniform integration.
Tracking#
This section describes how to activate tracking personalization and testing from Uniform in GA4.
Configure GA event#
In GA4, Event title and Event Category are deprecated in favor of parameters. To provide backward compatibility on tracking variants for personalization and tests on Uniform without title and category, you are required to manually create these custom dimensions for events in your Google Analytics dashboard.
Log into Google Analytics.
Navigate to your GA4 property.
Navigate to Configure > Custom definitions.
Add the following custom dimensions:
Dimension name Scope Event parameter Notes Event Category Event event_category
Event title Event event_title
Uniform Control Group Event is_control_group
Learn more about control groups for Uniform.
Activate GA plugin#
The Uniform tracker can dispatch event data to Google Analytics using a plugin. You must add this plugin to your front-end application.
If your application does not already use the Google Analytics global site tag (gtag.js), you must add the script.
About this step
In a web application, the global site tag must be added immediately after the head tag is closed, meaning it must be the first thing after
</Head>
.Add the following npm packages to your front-end application:
About this step
Make sure the package you add is version is 16.3 or greater.
Add the Google Analytics plugin to the Uniform Context object.
About this step
The Uniform Context object is passed to the tracker. The precise code used to add the tracker to your application depends on your front-end. For more information about the tracker, see the guide on how to add the Uniform tracker.
The plugin causes the tracker to fire GA4 events when Uniform
renders personalized components or variants for A/B tests on your application. Each event is accompanied by its corresponding event_title
, event_category
, and is_control_group
values.