Skip to content

Commit fdfbd78

Browse files
authored
Merge pull request #2704 from segmentio/ga4-best-practices
Add UA to GA4 section
2 parents d1629e5 + 9567cd7 commit fdfbd78

File tree

1 file changed

+52
-14
lines changed
  • src/connections/destinations/catalog/actions-google-analytics-4

1 file changed

+52
-14
lines changed

src/connections/destinations/catalog/actions-google-analytics-4/index.md

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ hide-boilerplate: true
55
hide-dossier: false
66
id: 60ad61f9ff47a16b8fb7b5d9
77
---
8-
[Google Analytics 4](https://support.google.com/analytics/answer/10089681){:target="_blank"} is Google's new Analytics property, which you can use for both websites and applications. Google Analytics 4 has machine learning at its core to help surface insights and give you a more complete understanding of your customers across devices and platforms.
8+
[Google Analytics 4](https://support.google.com/analytics/answer/10089681){:target="_blank"} is Google's new Analytics property, which you can use for both websites and applications. Google Analytics 4 has machine learning at its core to help surface insights and give you a more complete understanding of your customers across devices and platforms.
99

1010
When you have Segment installed, you can use your existing tracking implementation to fulfill your data collection needs with Google Analytics 4. Segment will send your data server-side to [Google's Measurement Protocol API](https://developers.google.com/analytics/devguides/collection/protocol/ga4).
1111

@@ -25,7 +25,7 @@ The Google Analytics 4 destination provides the following benefits:
2525

2626
Before you connect Segment to Google Analytics 4, configure a Google Analytics 4 property in your Analytics account. For more information, see Google's article: [Set up Analytics for a website and/or app](https://support.google.com/analytics/answer/9304153){:target='_blank'}.
2727

28-
To add the Google Analytics 4 destination:
28+
To add the Google Analytics 4 destination:
2929

3030
1. From the Segment web app, click **Catalog**, then click **Destinations**.
3131
2. Search for “Google Analytics 4” in the Destinations Catalog, and select the destination.
@@ -36,30 +36,68 @@ To add the Google Analytics 4 destination:
3636

3737
{% include components/actions-fields.html %}
3838

39-
## FAQ & Troubleshooting
39+
## Universal Analytics & Google Analytics 4
40+
41+
### Differences between Universal Analytics and Google Analytics 4
42+
43+
Google Analytics 4 uses an event-based data model similar to Segment, with the principle that any interaction can be captured as an event. Universal Analytics, on the other hand, is based on hits and is primarily pageview-based. Because the data collection models are different, data cannot be migrated from Universal Analytics to Google Analytics 4 and Google recommends recreating your existing Universal Analytics tracking in Google Analytics 4. For more information on the different data models, see Google’s [Events in Google Analytics 4 vs Universal Analytics](https://support.google.com/analytics/answer/11091422?hl=en&ref_topic=11091421){:target='_blank'} and [Universal Analytics versus Google Analytics 4 data](https://support.google.com/analytics/answer/9964640?hl=en&ref_topic=11192706){:target='_blank'}.
44+
45+
Google Analytics 4 has different out-of-the-box reports. Google Analytics 4’s reporting is much more configurable and supports new reporting metrics like churn probability and predictive revenue estimates. In addition, goals defined in Universal Analytics have been replaced with the concept of conversions in Google Analytics 4. Reports and conversions will need to be rebuilt in Google Analytics 4.
46+
47+
> info ""
48+
> To determine whether you have a Universal Analytics property or a Google Analytics 4 property, look at your property ID. Universal Analytics property IDs start with UA and end with a number (UA-XXXXXXXXX-1). Google Analytics 4 property IDs have only numbers (XXXXXXXXX).
49+
50+
### Migrating from Universal Analytics to Google Analytics 4
51+
> warning ""
52+
> Google announced that all standard Universal Analytics properties will stop processing new hits on July 1, 2023. 360 Universal Analytics properties will stop processing new hits on October 1, 2023.
53+
54+
Segment’s Google Analytics 4 integration is a server-side integration with the GA4 Measurement Protocol API. This is similar to Segment’s Google Universal Analytics cloud-mode integration in that all data is sent directly to Google’s servers. Please note that this means client-side functionality, such as [Enhanced Measurement](https://support.google.com/analytics/answer/9216061){:target='_blank'}, may not be available through Segment. In addition, as Google continues to develop the GA4 Measurement Protocol API ahead of general availability of the API, there may be limitations that impact what can be seen in the Google Analytics 4 reports.
55+
56+
#### Recommended Events
57+
Google Analytics 4 requires the use of [recommended events and properties](https://support.google.com/analytics/answer/9267735){:target='_blank'} to power certain built-in reports. Segment’s Google Analytics 4 destination will automatically map your [Segment spec](/docs/connections/spec/ecommerce/v2) events to the corresponding Google Analytics 4 events and properties. If your Segment events don't follow the Segment spec exactly, you can modify the mappings. For example, Segment maps "Order Completed" events to the Google Analytics 4 “Purchase” event by default. However, if your company uses “Products Purchase” to indicate a purchase, this can be mapped in the Purchase action’s Event Trigger instead.
58+
59+
Segment’s spec doesn't have an equivalent event for every Google Analytics 4 recommended event. If there are other recommended events you would like to send, please use the [Custom Event action](/docs/connections/destinations/catalog/actions-google-analytics-4/#custom-event). For example, to send a `spend_virtual_currency` event, create a mapping for Custom Event, set up your Event Trigger criteria, and input a literal string of "spend_virtual_currency" as the Event Name. You can use the Event Parameters object to add fields that are in the `spend_virtual_currency` event such as `value` and `virtual_currency_name`.
60+
61+
#### Custom Events
62+
In addition to recommended events, you can also send custom events using the [Custom Event action](/docs/connections/destinations/catalog/actions-google-analytics-4/#custom-event). Custom events are events that you name. Custom events don't appear in most standard reports; you need to set up custom reports for meaningful analysis. To create custom events in the Google Analytics 4 web interface, see Google’s [Modify and create events via the user interface](https://support.google.com/analytics/answer/10085872){:target='_blank'}.
4063

41-
### Custom Event Naming
64+
> info ""
65+
> Google Analytics 4 doesn't accept custom event names that include spaces. Segment replaces spaces in the Event Name in the Custom Event action with an underscore. As a result, you will see custom events snake-cased in Google Analytics 4. Google Analytics 4 is also case sensitive. If you would like all event names lowercased, use the **Lowercase Event Name** setting in the Custom Event action. If this setting is disabled, Google will treat event names with different casing as distinct events. For more information, see [Google Analytics 4 Event name rules](https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#event-name-rules){:target='_blank'}.
4266
43-
Google Analytics 4 does not accept custom event names that include spaces. Segment replaces spaces in the Event Name in the Custom Event action with an underscore. As a result, you will see custom events snakecased in Google Analytics 4.
67+
#### Custom Dimensions & Metrics
68+
With Google Analytics 4, you must create custom dimensions and metrics within the Google Analytics 4 interface and link parameters to the corresponding dimension or metric. When creating the dimension or metric, you can either select a parameter from the list of already collected fields or enter the name of the parameter you plan to collect in the future. To send parameters to Google Analytics 4, use the Event Parameters object available on every action.
4469

45-
Google Analytics 4 is also case sensitive. If you would like all event names lowercased, use the `Lowercase Event Name` setting in the Custom Event action. If this setting is disabled, Google will treat event names with different casing as distinct events. For more information, see [Google Analytics 4 Event name rules](https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#event-name-rules&zippy=%2Cin-this-article.%2Cin-this-article){:target="_blank"}.
70+
To achieve parity with Universal Analytics, you will probably want to create the same custom dimensions that you defined in Universal Analytics. Additionally, many of the values that you tracked as event dimensions in Universal Analytics, particularly event category and event label, should be recreated in Google Analytics 4 as custom dimensions. For more information, see Google’s [Google Analytics 4 Custom dimensions and metrics](https://support.google.com/analytics/answer/10075209){:target='_blank'}.
4671

47-
### Custom Dimensions & Metrics
72+
#### User Identification
73+
Segment requires a Client ID to send data to Google Analytics 4. The Client ID is the web equivalent of a device identifier and uniquely identifies a given user instance of a web client. By default, Segment sets Client ID to the Segment `userId`, falling back on `anonymousId`. This mapping can be changed within each action if you prefer to map a different field to Client ID.
4874

49-
With Google Analytics 4, you must create custom dimensions and metrics within the Google Analytics 4 interface and link event parameters to the corresponding dimension or metric. When creating the dimension or metric, you can either select a parameter from the list of already collected fields or enter the name of the parameter you plan to collect in the future. For more information, see [Google Analytics 4 Custom dimensions and metrics](https://support.google.com/analytics/answer/10075209?hl=en){:target="_blank"}.
75+
Segment also allows you to send a User-ID with your events. The User-ID feature lets you associate your own identifiers with individual users so you can connect their behavior across different sessions and on various devices and platforms. For more information on User-ID, see Google’s [Measure activity across platforms](https://support.google.com/analytics/answer/9213390){:target='_blank'} and [Reporting: deduplicate user counts](https://support.google.com/analytics/answer/9355949){:target='_blank'}.
76+
77+
There are certain scenarios where sending a User-ID can be helpful. For example, if you choose to integrate with Google Analytics 4 client-side (using Gtag outside of Segment) _and_ also use Segment's Google Analytics 4 destination to send events via API, you may consider taking the following approach:
78+
- **Use the Gtag-generated Client ID.** Gtag will set a Client ID automatically. The Client ID is stored in a cookie and can be fetched on the web client. To tie data between client-side and server-side, pass the Gtag-generated Client ID to Segment as a property and use that value as the Client ID in the Google Analytics 4 destination mappings.
79+
- **Use the Segment `userId` for User-ID.** The Segment `userId` should be your company’s canonical user identifier. By setting Google's User-ID to the same value as `userId` on client-side and server-side, you can benefit from cross-platform analytics.
80+
In addition, if you use [Firebase to send mobile data to Google Analytics 4](/docs/connections/destinations/catalog/actions-google-analytics-4/#mobile-data), using the same User-ID across web and mobile will ensure users are stitched together across devices.
81+
82+
User sessions are [not currently supported by the Measurement Protocol API](https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/limitations){:target="_blank"}, but should be coming soon. Once available, Segment will update the Google Analytics 4 destination to support sending session-level information.
83+
84+
#### Validating and Comparing Data
85+
Google recommends a period of dual-collection with both Universal Analytics and Google Analytics 4. This dual-collection approach lets you build a historical record in Google Analytics 4 while continuing to depend on Universal Analytics until you're ready to fully switch over.
86+
87+
During this period, you may find it hard to perfectly compare between the two properties because reports and configuration settings vary between Universal Analytics and Google Analytics 4 properties. Google provides guidance on the [conditions that must be met](https://support.google.com/analytics/answer/9964640?hl=en&ref_topic=11192706#comparing){:target="_blank"} in order to compare data in the Realtime reports, as well as [which metrics are comparable versus not](https://support.google.com/analytics/answer/11986666?hl=en&ref_topic=10737980){:target="_blank"}.
88+
89+
For a complete map of Universal Analytics functionality to corresponding Google Analytics 4 functionality, please see Google’s [Migration Reference](https://support.google.com/analytics/answer/10607999?hl=en&ref_topic=10737980){:target="_blank"}.
90+
91+
## FAQ & Troubleshooting
5092

5193
### Debug Mode
5294

5395
The Google Analytics 4 [debug mode](https://support.google.com/analytics/answer/7201382?hl=en){:target="_blank"} only works with a client-side implementation through gtag.js, Google Tag Manager, or Firebase. Because Segment’s Google Analytics 4 integration is server-side and uses the Measurement Protocol API, debug mode is not supported.
5496

5597
### Mobile Data
5698

57-
The Google Analytics 4 Measurement Protocol API is only compatible with web streams. Google requires use of their Firebase SDKs to send mobile data to Google Analytics 4. For more information on linking Google Analytics 4 properties to Firebase, see [Google Analytics 4 Firebase integration](https://support.google.com/analytics/answer/9289234?hl=en){:target="_blank"}.
99+
The Google Analytics 4 Measurement Protocol API is only compatible with web streams. Google requires use of their Firebase SDKs to send mobile data to Google Analytics 4. To assist in your implementation, Segment has a [Firebase destination](/docs/connections/destinations/catalog/firebase) available for mobile analytics. For more information on linking Google Analytics 4 properties to Firebase, see [Google Analytics 4 Firebase integration](https://support.google.com/analytics/answer/9289234?hl=en){:target="_blank"}.
58100

59101
### User Metrics & Sessions
60102

61-
Segment sends a Google `clientId` in requests to the Measurement Protocol API, alongside other required API fields. However, user sessions are [not currently supported by the Measurement Protocol API](https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/limitations){:target="_blank"}, so user metrics might not appear on the Google Analytics 4 Realtime report or several other reports.
62-
63-
To validate your implementation, check users and events on the Events report and User Explorer.
64-
65-
103+
Segment sends a Google Client ID in requests to the Measurement Protocol API, alongside other required API fields. However, user sessions are [not currently supported by the Measurement Protocol API](https://developers.google.com/analytics/devguides/collection/protocol/ga4/reference/limitations){:target="_blank"}, so user metrics might not appear on the Google Analytics 4 Realtime report or several other reports. To validate your implementation, check users and events on the Events report and User Explorer.

0 commit comments

Comments
 (0)