Configure CSS Selectors for Dynatrace User Tagging

Hi @dave_mauney , I’m trying to extract via css selector the content of <homepage-element> you can see below.

paolo_fumanelli_1-1689089229258.png

At first, I’d like to use a part of its content as action property.

In the capture expression I indicated this (following your very useful guide):

#body > app-root > app-homepage > div > div.element-wrapper > div:nth-child(1) > homepage-element

But unfortunately it’s not capturing anything.

Do you have any hint for me?

Thanks
Paolo

Buongiorno, Paolo…come stai oggi?

I am not a CSS guru by any means.  But if you can send me a bit more of the page, or point me to a public URL I can take a look. My email is dave dot mauney at dynatrace dot com.

Ciao, dave

Grazie Dave spero anche tu :slightly_smiling_face:

Unfortunately this is a brand new page and it’s available only on our QA environment so I can’t point you to a public URL. I sent you an email, thanks a lot

@paolo_fumanelli  it’s not clear from the screenshot what the <homepage-element> contains.  RUM will capture the textContent attribute.

Based on your example you might want to try selector

homepage-element@country

to capture the country attribute from the element.

You can also use the browser’s developer console:

document.querySelector("homepage-element")

Dear Julius, I finally managed to let it work by applying CSS selector in this way

#body > app-root > app-homepage > div > div.element-wrapper > div:nth-child(1) > homepage-element@country

Thanks a lot for your help!

You are welcome!  
I recommend leaving out the CSS hierarchy and rewrite the selector in a way so that any future modifications of the page won’t affect it (for example nth-child). So unless there are no more homepage-element tags in your page, you can probably safely delete the part before it.

Well, that was also my concern so I tried that but it didn’t capture anything, that’s why I turned to the current solution where I take “Copy selector” as it is without any transformation…

@Christopher_Cha This is just a temporary solution.
CSS is not best practice for this, espectialy with complex css path 
which can be changed with layout in any time.

Try to ask developers add JS variable or dtrum.identifyUser(“xxxx”) call for 100% reliable user detection

I agree!  If possible, use more stable solutions as @Christopher_Cha mentioned!

@dave_mauney Could you share once again please?

Here is a copy of the Powerpoint.
HowToSpecifyUserTagCSSSelector.pptx (4.65 MB)

Try the attached Powerpoint above.