# Configure CSS Selectors for Dynatrace User Tagging

**URL:** <https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209>\
**Category:** Real User Monitoring\
**Tags:** real-user-monitoring-classic, user-sessions\
**Created:** [March 8, 2018, 2:02am UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209 "2018-03-08T02:02:35Z")\
**Posts on this page:** 12\
**Page:** 2

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [July 11, 2023, 3:29pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/21 "2023-07-11T15:29:47Z")

</div>

Hi&nbsp;[@dave\_mauney](https://community.dynatrace.com/user/771)&nbsp;, I’m trying to extract via css selector the content of \<homepage-element\> you can see below.

![paolo_fumanelli_1-1689089229258.png](https://global.discourse-cdn.com/dynatrace/optimized/3X/4/0/404d6b6510dc8a612c2c7d4b5c53cacc99abc3f7_2_690x23.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

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [July 11, 2023, 3:37pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/22 "2023-07-11T15:37:54Z")

</div>

Buongiorno, Paolo…come stai oggi?

I am not a CSS guru by any means.&nbsp; 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

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [July 11, 2023, 3:51pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/23 "2023-07-11T15:51:31Z")

</div>

Grazie Dave spero anche tu 🙂

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

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [July 11, 2023, 4:03pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/24 "2023-07-11T16:03:25Z")

</div>

[@paolo\_fumanelli](https://community.dynatrace.com/user/19328)&nbsp; it’s not clear from the screenshot what the \<homepage-element\> contains.&nbsp; RUM will capture the textContent attribute.

Based on your example you might want to try selector

```markup
homepage-element@country

```

to capture the country attribute from the element.

You can also use the browser’s developer console:

```markup
document.querySelector("homepage-element")

```

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [July 12, 2023, 8:34am UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/25 "2023-07-12T08:34:53Z")

</div>

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](mailto:homepage-element@country)

Thanks a lot for your help!

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [July 12, 2023, 9:44am UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/26 "2023-07-12T09:44:53Z")

</div>

You are welcome!&nbsp;&nbsp;  
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.

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [July 12, 2023, 9:47am UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/27 "2023-07-12T09:47:31Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Slawa](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@Slawa](https://community.dynatrace.com/u/Slawa)\
**Post date:** [July 26, 2023, 12:27pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/28 "2023-07-26T12:27:15Z")

</div>

[@Christopher\_Cha](https://community.dynatrace.com/user/6257)&nbsp;This is just a temporary solution.  
CSS is not best practice for this, espectialy with complex css path&nbsp;  
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

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [July 26, 2023, 1:43pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/29 "2023-07-26T13:43:19Z")

</div>

I agree!&nbsp; **If possible** , use more stable solutions as&nbsp;[@Christopher\_Cha](https://community.dynatrace.com/user/6257)&nbsp;mentioned!

---

<div class="post-metadata">

**Author:** ![Vidhyasagar](https://avatars.discourse-cdn.com/v4/letter/v/a9adbd/32.png) [@Vidhyasagar](https://community.dynatrace.com/u/Vidhyasagar)\
**Post date:** [August 1, 2023, 12:01pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/30 "2023-08-01T12:01:57Z")

</div>

[@dave\_mauney](https://community.dynatrace.com/user/771)&nbsp;Could you share once again please?

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [August 1, 2023, 1:15pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/31 "2023-08-01T13:15:50Z")

</div>

Here is a copy of the Powerpoint.  
[HowToSpecifyUserTagCSSSelector.pptx](https://community.dynatrace.com/uploads/short-url/8Wv50gUgIR9gqRiT6cAKOfRHEvk.pptx) (4.65 MB)

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [August 1, 2023, 1:17pm UTC](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209/32 "2023-08-01T13:17:08Z")

</div>

Try the attached Powerpoint above.

[Previous page](https://community.dynatrace.com/t/configure-css-selectors-for-dynatrace-user-tagging/11209.md?page=1)
