Step by Step to Teach You to Set User ID in Google Analytics 4(2024) | BCS Step by Step to Teach You to Set User ID in Google Analytics 4(2024) | BCSBCS

Step by Step to Teach You to Set User ID in Google Analytics 4(2024)

Google Analytics BCS 2 years ago (2023-01-18) 2061 Views 0 Comments

This article introduces how to set the User ID in GA4.

Usually, the User ID is also set as User Properties to facilitate the subsequent use of the User ID in GA4.

User ID

User ID is your own ID system, User ID lets you associate your own identifiers with individual users so you can connect their behavior across different sessions and on various devices and platforms.

Since GA4 is not allowed to send PII information, it usually encrypts the sent ID, such as using its Hash value.

Configuration

Next, demonstrate how to Set User ID to  GA4, assume User ID is Email ID,my Email ID is [email protected], the Hash value is c046f9efa4a3d9c5bc14a2a56f870933after.

 

Variable

The first step is to obtain the Email ID of the user after login through Variable, there are multiple ways:

  • 1st Party Cookie:After the user logs in, the Email ID is stored in the Cookie, and then the 1st Party Cookie is used to obtain it. The disadvantage of this method is that if the cookie is not allowed, the User ID will be lost.
  • JavaScript Variable:After the user logs in, store the Email ID in JavaScript Variable, and then use JavaScript Variable to get it.
  • Data Layer Variable:After the user logs in, send the Email ID through dataLayer.push, and then use Data Layer Variable to get it.

So I suggest using JavaScript Variable, the code that needs to be added to the page is as follows:

<script>
	user_id="c046f9efa4a3d9c5bc14a2a56f870933after";
</script>

Note: This code is required for all pages after login.

 

In GTM, click 「Variables」——「New」——「Choose a variable type to begin setup…」——「JavaScript Variable」 then name it “User ID”, and configure as follows:

Step by Step to Teach You to Set User ID in Google Analytics 4(2024)

The function of this configuration is to use theJavaScript Variable to obtain the user_id in the JavaScript Variable

 

Tags

The next step is to set the User ID and User Properties.

Open GA4’s tag, and configure as follows:

Step by Step to Teach You to Set User ID in Google Analytics 4(2024)

Note that this setting is in GA4’s tag.

user_id is a system built-in field and is fixed.

user_id_custom_dimension is custom, is to set User Properties.

{{User ID }} in value is the variable set in the previous step.

 

Preview

The next step is Preview to see if the user_id can get an accurate value.

Click 「Preview」in GTM:

Step by Step to Teach You to Set User ID in Google Analytics 4(2024)

 

Enter https://www.bbccss.com in Tag Assistant:

Step by Step to Teach You to Set User ID in Google Analytics 4(2024)

Uncheck “Include debug signal in the URL” and click “Connect”.

Enter the test state and return to Tag Assistant,Click 「Container Loaded」, then click GA4’s Tag, click 「value」 in the upper right corner

Step by Step to Teach You to Set User ID in Google Analytics 4(2024)

You can see that user_id is  email id’s hash.

 

Custom definitions

Next, you need to register user_id_custom_dimension as User Scope Custom Dimension in GA4, and then you can use it in GA4 reports.

Click「Admin」——「Custom definitions」——「Create custom dimension」in GA4, and then configure as follows:

Step by Step to Teach You to Set User ID in Google Analytics 4(2024)

Scope selects Users, indicating that it is User Scope Custom Dimension.

 

 

Note

GA4 is not allowed to send PII information.


If you don't understand, You can leave a comment below.
Like (1)
Post my comment
Cancel comment
Expression Bold Strikethrough Center Italic

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • Website