Identify individual users for session analysis

One of the key features of Dynatrace Real User Monitoring is the ability to uniquely identify individual users across different browsers, devices, and user sessions. This enables you to analyze the user experience of individual users via user session analysis. With user tags, you can track specific user behavior throughout your application environment, across sessions, devices, and browsers.

By default, Dynatrace assigns a unique, random ID to each new user. You can however assign more meaningful user tags that are comprised of, for example, user names or email addresses.

​You can set up custom user tagging via either the Dynatrace JavaScript API or page metadata.

User tagging via the Dynatrace JavaScript API

User tagging can be orchestrated via the Dynatrace JavaScript API for Real User Monitoring. Samples and documentation can be downloaded from the Dynatrace UI:

  1. Go to Settings > Web and mobile monitoring > Advanced setup.
  2. Click Download documentation and samples. A sample HTML file called identifyUser.html with a correctly formatted JavaScript snippet can be found in the samples\sessions directory.

User tagging based on page metadata

This approach to user tagging works by capturing available data in your application’s 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, easyTravel, the Dynatrace demo application, includes the user name in a welcome message in the upper-right corner of the home page (see image below). Using the development tools that are built into most browsers, you can generate a unique CSS selector for this particular element.

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. Click Add tag (identifier) rule.
  6. From the Expression type to capture drop list, select CSS selector.
  7. Type the CSS selector value into the CSS selector field.
  8. (optional) To ensure that there is a clean extraction of the username value, you can apply a regex cleanup rule by enabling the Enable cleanup rule switch and then typing a regular expression in the Regex field.
  9. Click Add tag (identifier) rule and then click Save.
    Note: You can add a maximum of 20 user tag (identifier) rules per application.

To verify that your user tag configuration has been applied correctly, after saving the configuration and reloading the page, 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.

Once you’ve completed this process, select User sessions from the navigation menu. Click in the filter text box at the top of the page. Choose the User tag attribute and select a user tag from the list. The chart now shows detailed session data related to the sessions of this specific user. You can click the name of the user that appears under the chart to navigate to this user’s overview page and view further details.

User tagging based on request attributes

Note: This feature is currently available as a Preview.

With release 1.161, Dynatrace allows you to use server-side request attributes to tag each user session. Once you've defined a request attribute, all you need to do is execute the steps below.

  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. Click Add tag (identifier) rule.
  6. From the Expression type to capture drop list, select Server side request attribute.
  7. From the drop-list, select the Request attribute name you want Dynatrace to use for user tagging.

Note that the service request attribute may not be captured for every user action/user session, as your server-side PurePath may be not captured due to adaptive capture control.

Additional notes

  • If you use the JavaScript API to identify your users, the API may override any existing metadata rules that have been configured. So, if you define user tags through the JavaScript API, these user tags will override any other metadata-based tags that may exist.
  • All configured user tags are captured on every page. JavaScript code is used to evaluate each monitored user action against each user-tag rule that you create, so keep your list of user-tag rules to a minimum to reduce overhead.
  • The last user action in a session that contains a tag will be used as the tag for the entire session.
  • You can also identify mobile users of native mobile apps.