# Need to stored user count for longer timeframe

**URL:** <https://community.dynatrace.com/t/need-to-stored-user-count-for-longer-timeframe/41033>\
**Category:** Real User Monitoring\
**Tags:** real-user-monitoring-classic, data-privacy-and-product-security, usql, user-sessions\
**Created:** [August 4, 2023, 4:37am UTC](https://community.dynatrace.com/t/need-to-stored-user-count-for-longer-timeframe/41033 "2023-08-04T04:37:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noor\_afrians](https://avatars.discourse-cdn.com/v4/letter/n/4af34b/32.png) [@noor\_afrians](https://community.dynatrace.com/u/noor_afrians)\
**Post date:** [August 4, 2023, 4:37am UTC](https://community.dynatrace.com/t/need-to-stored-user-count-for-longer-timeframe/41033/1 "2023-08-04T04:37:47Z")

</div>

Hi,

i am trying see user count in range 6 month.

currently i am using this query to show the total user. but this is only last 35 day due retention period.

```markup
SELECT Count(DISTINCT(userid)) FROM usersession where userId IS NOT NULL

```

in my mind it is need to create user session custom metric, but i cannot find the proper way to setup like USQL above.

is there someone facing same problem with me and have solution ?

thanks

---

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [August 4, 2023, 6:33am UTC](https://community.dynatrace.com/t/need-to-stored-user-count-for-longer-timeframe/41033/2 "2023-08-04T06:33:58Z")

</div>

Hi&nbsp;[@noor\_afrians](https://community.dynatrace.com/user/45733)

For this you can cerate a small automation code that will run&nbsp;[User sessions API](https://www.dynatrace.com/support/help/shortlink/api-usql-table)&nbsp;with your select and push back the information to dynatrace as a metric with&nbsp;[Metrics API - POST ingest data points](https://www.dynatrace.com/support/help/shortlink/api-metrics-v2-post-datapoints)

If you need minutes interval then create an [AG extension](https://www.dynatrace.com/support/help/shortlink/activegate-extensions-intro#what-is-the-activegate-extensions-architecture) that will run the code every minute ,if its for longer intervals use some scheduler to run it every no and than.

HTH

Yos
