User retention/churn calculation

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

  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
Is there away to aggregate users life time > some retention period in the

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


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
To view this discussion on the web visit
For more options, visit

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

@raghvendra @Raz_Lachyani

did you guys figure out any approach for this?

Behavioural analysis is best done using an entity-centric index.