# User retention/churn calculation

**URL:** https://discuss.elastic.co/t/user-retention-churn-calculation/20230
**Category:** Elasticsearch
**Created:** [October 14, 2014, 7:39am UTC](https://discuss.elastic.co/t/user-retention-churn-calculation/20230 "2014-10-14T07:39:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Raz\_Lachyani](https://avatars.discourse-cdn.com/v4/letter/r/f9ae1b/32.png) [@Raz\_Lachyani](https://discuss.elastic.co/u/Raz_Lachyani)
#### Post date: [October 14, 2014, 7:39am UTC](https://discuss.elastic.co/t/user-retention-churn-calculation/20230/1 "2014-10-14T07:39:52Z")

</div>

Hi Guys,

I need to get user retention from Elasticsearch.  
My algorithm is:

retention\_period = 60 days

1. start\_registrations\_date = today - retention\_period - 30 days

2. end\_registrations\_date = today -retention\_period

3. Get all users born in start\_registrations\_date to end\_registrations\_date

4. user\_lifeTime = (day that user was last seen) - (day that user  
registered)

5. Retention = ((#users with user\_lifeTime \> retention\_period ) / #users)

- 100

I have registration event that looks something like this :

{  
userId : "raz",  
createDate : "10-10-2014T11:00:00"  
}  
.  
.  
.

And ping event that looks something like this:

{  
userId : "raz",  
createDate : "10-10-2014T13:00:00"  
},  
{  
userId : "raz",  
createDate : "10-10-2014T14:00:00"  
}  
.  
.  
.

Now to my question:

How do you recommend to achieve the retention using the aggregation  
platform?  
Is there away to aggregate users life time \> some retention period in the  
system?

I hope solving this issue will help someone here because calculating  
retention/churn is a very common analytic.

Thanks,  
Raz.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/49fd4b68-c454-4862-9e9e-f82183bc974d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/49fd4b68-c454-4862-9e9e-f82183bc974d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![raghvendra](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@raghvendra](https://discuss.elastic.co/u/raghvendra)
#### Post date: [June 20, 2017, 6:19am UTC](https://discuss.elastic.co/t/user-retention-churn-calculation/20230/2 "2017-06-20T06:19:14Z")

</div>

Same , i also want to do with my data .  
Can anyone help ?

---

<div class="post-metadata">

### Author: ![enVolt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/envolt/32/43550_2.png) [@enVolt](https://discuss.elastic.co/u/enVolt)
#### Post date: [May 21, 2019, 9:55am UTC](https://discuss.elastic.co/t/user-retention-churn-calculation/20230/3 "2019-05-21T09:55:56Z")

</div>

@raghvendra @Raz_Lachyani

did you guys figure out any approach for this?

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [May 21, 2019, 10:08am UTC](https://discuss.elastic.co/t/user-retention-churn-calculation/20230/4 "2019-05-21T10:08:31Z")

</div>

Behavioural analysis is best done using an [entity-centric](https://twitter.com/elasticmark/status/1009380268409610240?s=20) index.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 4, 2022, 4:01am UTC](https://discuss.elastic.co/t/user-retention-churn-calculation/20230/5 "2022-11-04T04:01:25Z")

</div>


