Configure CSS Selectors for Dynatrace User Tagging

Summary: The post shows how to create CSS selector rules to capture usernames or IDs in Dynatrace RUM. It includes tips for validating selectors and ensuring consistent tag extraction.

Hey guys,

I’m in the midst of deploying Dynatrace Managed for a customer, and I’m not really familiar with the CSS part for user tagging. We have identified the CSS element that contains the user name, but I’m just not too sure if the configuration is correct. Could you help me verify?

Attached is a screenshot, and the highlighted part is the user name we want to capture. Would “#navTabButtonUserInfoText navTabButtonUserInfoWorker@title” work? As I will not be on-site until next week and the customer is new to the product, I’d just thought of getting opinions here first…

Chris

Chris,

First, capture the correct CSS selector by selecting your element from the WebGUI, then click right and select Inspect. You have this option in Chrome and Firefox, not in IE.

Then in the HTML editor, click on “copy as CSS”, past in Dynatrace and that’s done

In some cases, that may not be sufficient because you are capturing extra characters or strings. Then use a regex that you will put under the “Apply cleanup rule” option in the “User tag” rule of your Dynatrace application.

You can also have a look here:

Regards,

Hi Chris,

Here’s a brief step-by-step PowerPoint that may help also, especially if you want to test the CSS selector before you add it to Dynatrace:

https://dynatrace-my.sharepoint.com/:p:/p/dave_mau…

HTH,

dave

Thanks guys! The one that worked is #navBarUserInfoTextId > span.navTabButtonUserInfoText.navTabButtonUserInfoWorker.

Great thanks for sharing this Chris, very helpful for user tagging in MS Dynamics!

just to clear details:

to get value of attribute title it should be:

#navBarUserInfoTextId > span.navTabButtonUserInfoText.navTabButtonUserInfoWorker@title

Hi @dave_mauney

Can you please share this PPT again as I’ve tried to access it, I find It’s expired.

Thanks.

I shared it again here:

HowToSpecifyUserTagCSSSelector.pptx

Our corporate policy is to set a 90 expiration on links shared on SharePoint, so the clock starts again now…

@dave_mauney Could I ask you to share again please?

HowToSpecifyUserTagCSSSelector.pptx (expires July 27th, 2023)

This is not working anymore on latest version 9.1.x of MS Dynamics 365 on prem.

Hello, I am trying to extract the name John for user tagging using CSS selector.

<a _ngcontent-sba-c1="" aria-label="My Profile" class="user-label ng-star-inserted" href="ABCD"><span _ngcontent-sba-c1="" class="check-dirty user-name">Hello, John</span><img _ngcontent-sba-c1="" alt="user" class="check-dirty user-profile" src="XYZ.svg"></a>

I followed the same instructions to copy the selector and this is what I input into the app config for user tagging. It still keep the User names in sessions as Anonymous:

#page-main-container > div.bmo-container > div:nth-child(1) > a > span

Am I missing something here which is not letting the user tag parse through?

Did you test the selector in the dev tools console as covered in the PPT above?  I am no CSS expert, but you might want to try a selector of “.check-dirty user-name” and see if that works should be less “brittle” than the selector you are trying now.

Yes I did test it, I get NULL as a response for some reason. Couldn’t understand why:

Update - This seems to work -

document.querySelector("span.check-dirty.user-name").innerHTML

rohan1shah_0-1685724386510.png

But when I input that as part of the User Tagging Rules, there still seems to be no change. All sessions show up as anonymous:

And you are sure new logins have occurred after the change?

Yes, I have been doing the logins myself and can see new sessions showing up from other users too in DT.

The User Tag CSS selector “hint” says it will capture “innerText/textContent” so you may want to see what that gives in the console.

Still unable to get any output.

I would try the in-product chat for some help.  I am out of ideas.