# Session Property Cleanup rule

**URL:** <https://community.dynatrace.com/t/session-property-cleanup-rule/20509>\
**Category:** Open Q&A\
**Tags:** request-attributes\
**Created:** [October 9, 2020, 10:08pm UTC](https://community.dynatrace.com/t/session-property-cleanup-rule/20509 "2020-10-09T22:08:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkulov](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mkulov/32/11732_2.png) [@mkulov](https://community.dynatrace.com/u/mkulov)\
**Post date:** [October 9, 2020, 10:08pm UTC](https://community.dynatrace.com/t/session-property-cleanup-rule/20509/1 "2020-10-09T22:08:47Z")

</div>

Hi,

I am trying to set session property when specific query parameter string matches one of two options.

Let say the query parameter can contain string OptionA, OptionB, or anything else.

I want to create cleanup rule that will clean everything else but OptionA and OptionB within the string.

The goal is to have the session property set only when query parameter contains either OptionA or OptionB. For any other values - the session property should not be set.

Do you if this is possible with some regex cleaning rule?

If so - any tips how to do that?

Thank you,

Martin

---

<div class="post-metadata">

**Author:** ![wouter\_camps](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/wouter_camps/32/31564_2.png) [@wouter\_camps](https://community.dynatrace.com/u/wouter_camps)\
**Post date:** [October 13, 2020, 4:29pm UTC](https://community.dynatrace.com/t/session-property-cleanup-rule/20509/2 "2020-10-13T16:29:03Z")

</div>

Hi,

I don’t know whether this is possible using Session Property clean up rules (if so, i’d like to know :).

If you don’t mind defining a **request attribute** at the _environment_ level (so not the application level), I think you should be able to implement what you’re looking for using a request attribute based session property.

via Settings → Server-side service monitoring → Request attributes → Define a new request attribute

fill in the ‘Request attribute name’ e.g ‘OptionA\_or\_OptionB’

click “Add new data source”

select “Web request URL query parameter” (below description ‘Specify where the attribute is captured and then stored’)

fill in the ‘Parameter name’

click/pull down ‘Further restrict or process captured parameters (optional)’

fill in 5. Extract value from captured data per regex:

(OptionA|OptionB)

Save

At the application level, add a “Custom defined property”

select expression type ‘Server side request attribute’

select ‘Request attribute name’ → ‘OptionA\_or\_OptionB’

click ‘Store as session property’

Save property

Hope this was helpful,

Kind regards,

Wouter

---

<div class="post-metadata">

**Author:** ![mkulov](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mkulov/32/11732_2.png) [@mkulov](https://community.dynatrace.com/u/mkulov)\
**Post date:** [October 15, 2020, 7:58pm UTC](https://community.dynatrace.com/t/session-property-cleanup-rule/20509/3 "2020-10-15T19:58:15Z")

</div>

Hi Wouter,

Indeed I ended up with request attribute instead.

Thank you,

Martin
