Header background

Automatic identification of users based on page metadata

One of the key features of Dynatrace Real user monitoring is our ability to uniquely identify your users across different browsers and devices. This enables you to analyze the user experience of individual users during user session analysis. Dynatrace initially assigns a unique, random ID to each new user. There are however a few different ways to assign more meaningful user tags to your users. You may already know how to use the JavaScript API to assign custom tags to users. This article explains another approach to tagging your users that works by capturing available data in your application’s page source—there’s no need to add additional code to your application.

Identify users

Locate usernames in page source

If you take a close look at your application’s page source, you’ll likely find that usernames are already included somewhere. Usernames may be included in the text of a DOM element, a meta tag, a JavaScript variable, or even a cookie attribute. For example, Easy Travel, the Dynatrace demo application, includes the user name in a welcome message in the upper-right corner of the home page. Using the development tools that are built into most browsers, we can easily generate a unique CSS selector for this particular element.

user identification

Create a user tag

Once you’ve identified where usernames are located in your page source, you can create user tags based on the usernames.

  1. From the navigation menu, click Applications.
  2. Select the application you want to configure.
  3. Click the Browse (…) button and select Edit.
  4. Click the User tags tab.
  5. From the Capture expression type drop list, select CSS selector.
  6. Type the CSS selector value into the CSS selector field.
  7. To ensure that there is a clean extraction of the username value, you can apply a regex cleanup rule.

That’s all there is to it!

Verify your user tag

To verify that your user tag configuration has been applied correctly, take a look at the injected JavaScript tag in your application’s updated page source. As you can see in the example below, a property called md= is now listed in this page’s metadata expressions.

Additional notes

  • If you’re using the JavaScript API to identify your users, any metadata rules that you configure may be overruled.
  • All configured user tags will be captured on every page. So keep the list short.
  • The last user action in your session that contains a tag will be used as tag for the entire session.
  • You can also report user names for native mobile apps.
Please go to the documentation for up-to-date instructions.