# Session property based on JavaScript variable - use of key?

**URL:** <https://community.dynatrace.com/t/session-property-based-on-javascript-variable-use-of-key/20212>\
**Category:** Real User Monitoring\
**Tags:** user-sessions\
**Created:** [April 1, 2019, 3:49pm UTC](https://community.dynatrace.com/t/session-property-based-on-javascript-variable-use-of-key/20212 "2019-04-01T15:49:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff\_rowell](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@jeff\_rowell](https://community.dynatrace.com/u/jeff_rowell)\
**Post date:** [April 1, 2019, 3:49pm UTC](https://community.dynatrace.com/t/session-property-based-on-javascript-variable-use-of-key/20212/1 "2019-04-01T15:49:56Z")

</div>

I’m trying to configure a Session Property that references a JavaScript variable. In the session property rule, the interface is demanding that I provide a “key”. I have not been able to find any documentation of what the purpose of this “key” is. Why is it not enough to simply reference the name of the JavaScript variable? What should the “key” be set to?

---

<div class="post-metadata">

**Author:** ![skrystosik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/skrystosik/32/21133_2.png) [@skrystosik](https://community.dynatrace.com/u/skrystosik)\
**Post date:** [April 2, 2019, 6:38am UTC](https://community.dynatrace.com/t/session-property-based-on-javascript-variable-use-of-key/20212/2 "2019-04-02T06:38:37Z")

</div>

Key is just the name that will be use as index in DT. You can have different key and display name (optional).

Sebastian

---

<div class="post-metadata">

**Author:** ![jeff\_rowell](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@jeff\_rowell](https://community.dynatrace.com/u/jeff_rowell)\
**Post date:** [April 2, 2019, 3:55pm UTC](https://community.dynatrace.com/t/session-property-based-on-javascript-variable-use-of-key/20212/3 "2019-04-02T15:55:29Z")

</div>

I’m not really clear as to what is meany by “index”… however, what I have found is that the Display Name value seems to be ignored and the session property shows up in the user session with a label that is identical to the value that I put into the “key” field.

---

<div class="post-metadata">

**Author:** ![Dant3](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dant3/32/159_2.png) [@Dant3](https://community.dynatrace.com/u/Dant3)\
**Post date:** [April 2, 2019, 4:14pm UTC](https://community.dynatrace.com/t/session-property-based-on-javascript-variable-use-of-key/20212/4 "2019-04-02T16:14:51Z")

</div>

Key is, as you already notice, the field name given to the detected values.

So if we got a “market” variable the key could be “detected\_market”. So when you search the string or double object in the session that would be it’s name. detected\_market = 3 or what ever. Is a required field.

---

<div class="post-metadata">

**Author:** ![jeff\_rowell](https://avatars.discourse-cdn.com/v4/letter/j/779978/32.png) [@jeff\_rowell](https://community.dynatrace.com/u/jeff_rowell)\
**Post date:** [April 2, 2019, 4:50pm UTC](https://community.dynatrace.com/t/session-property-based-on-javascript-variable-use-of-key/20212/5 "2019-04-02T16:50:53Z")

</div>

Thanks Dante. Thanks for clarifying that the key is essentially just the name that you want to assign to the extracted values. It would appear that Display Value doesn’t work however.

---

<div class="post-metadata">

**Author:** ![Dant3](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dant3/32/159_2.png) [@Dant3](https://community.dynatrace.com/u/Dant3)\
**Post date:** [April 2, 2019, 5:22pm UTC](https://community.dynatrace.com/t/session-property-based-on-javascript-variable-use-of-key/20212/6 "2019-04-02T17:22:26Z")

</div>

I didn’t actually try the “Display value”, maybe is something as an alias for the key, idk. You also can’t create a key, delete it and then create it again. Since an error will show that the key already exists. That is when i understood the meaningn of the fiel. Sadly it take me 3 session properties to understand it. It’s a nice really addtion. Hope it reaches the Mobile app also.
