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.
This article describes how to send user IDs from your website once you've generated the user IDs. To learn more about the User-ID feature, see Measure activity across platforms. To learn how to set a user ID for an app, see Set a user ID instead.
Before you begin
This guide assumes that you've done the following:
- Create a Google Analytics 4 account and property
- Create a web data stream for your website
- Place the Google tag on your website
It also assumes that you have the following:
- Access to your website source code
- The Editor role to the Google Analytics account
Send user IDs
To send a user ID to Analytics, add the user_id
parameter to the config
command in the measurement code on each page of your website. Using the
following snippet, replace G-XXXXXXXX
with your tag ID and USER_ID
with
the generated user ID.
gtag('config', 'TAG_ID', { 'user_id': 'USER_ID' });