Send user IDs

User IDs are your own unique identifiers that you assign to individual users. This guide explains how to send user IDs to Google Analytics, so you can connect user behavior across different sessions, devices, and platforms.

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.

To avoid issues with your reporting and data accuracy, make sure you follow these best practices:

  • Don't set custom dimensions based on user IDs. Setting custom dimensions based on user IDs leads to dimensions with too many unique values. Having too many unique values causes issues with Google Analytics data and reporting accuracy. Learn more about best practices for setting custom dimensions.
  • Don't send a user ID when a user isn't signed in. If a user isn't signed in, don't pass the user ID parameter, or leave the value as undefined. Don't set a custom value, like "empty" or "NA". Setting the same value for all sessions without a user signed in causes issues with the accuracy of your reporting.


Before you begin

Before you can send user IDs, make sure you've completed the following:

Send user IDs

Step 1: Update your data layer

Before you send user IDs to Analytics, make the user_id available in your data layer on your website.

dataLayer.push({
  'user_id': 'USER_ID'
});

Step 2: Create a data layer variable

  1. In Google Tag

    Manager, click Variables.

  2. In the User-Defined Variables section, click New.

  3. Click Variable Configuration > Data Layer Variable.

  4. Enter a name for the variable at the top.

  5. In the Data Layer Variable Name field, enter a name for your user ID variable (such as "user_id").

  6. Click Save.

Step 3: Modify your Google tag

Finally, modify the Configuration tag so all events associated with the tag use the Data Layer variable:

  1. In Tag Manager, click An image of the Tags icon Tags.
  2. Select your Google tag.
  3. Under Configuration settings section, add a new row with the following parameters:
    • Parameter: user_id
    • Value: Select the Data Layer variable you created.
  4. Click Save.
  5. Click Submit to publish the changes.