Track user ID

The Universal Analytics User ID is used to associate multiple user sessions and activities with a unique ID. With it, you can get a more accurate user count, analyze the signed-in user experience, and understand user behavior across devices. You can use Tag configuration

To

To configure Universal Analytics tags to capture the User ID with Tag Manager:

  1. Create a Tag Manager variable called userId. Your variable can retrieve the user ID value from either a first party cookie or the data layer:
    • If you're using a 1st party cookie to store a user ID on the client web browser, you can use the 1st party cookie variable to read the user ID value from the cookie. Create a new 1st Party Cookie variable, and enter the name of your cookie in the Cookie Name field.
    • If the user ID is available on the page itself, you can create a data layer variable. Create a new Data Layer variable and enter the variable name in the Data Layer Variable Name field.
  2. In your Universal Analytics tag, open More settings and then Fields to Set.
  3. Click Add Field. Enter these values for the new field:
    Field Name Value
    userId {{userId}}
  4. Save the tag and publish the changes.

Remove the User ID

The Google Analytics User ID policy requires that you stop tracking the user ID once the user signs out of your website.

If the user ID is stored in a cookie, tags can read the user ID value from the cookie. You should delete the cookie whenever a user signs out.

When the cookie is deleted, tags will not send the user ID to Google Analytics. If the user signs back in, a new cookie will be set and your tags will send the user ID to Google Analytics.

Was this article helpful?
How can we improve it?