# How to do a cohort analysis using a heatmap

**URL:** <https://discuss.elastic.co/t/how-to-do-a-cohort-analysis-using-a-heatmap/251091>\
**Category:** Kibana\
**Created:** [October 6, 2020, 9:06am UTC](https://discuss.elastic.co/t/how-to-do-a-cohort-analysis-using-a-heatmap/251091 "2020-10-06T09:06:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Handle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/max_handle/32/48133_2.png) [@Max\_Handle](https://discuss.elastic.co/u/Max_Handle)\
**Post date:** [October 6, 2020, 9:06am UTC](https://discuss.elastic.co/t/how-to-do-a-cohort-analysis-using-a-heatmap/251091/1 "2020-10-06T09:06:36Z")

</div>

Hi,  
I tried to find a solution online, but I haven't found any answer yet. I am trying to do a cohort/ customer retention analysis. The picture shows my take on this. **What I want:**  
I want to see whether customers that were active 4 weeks ago came back to the website in the subsequent weeks _(i.e. relative time filter)_.  
I have a classical **useId** and **sessionId** that I could work with.

Anyone has an idea how one could do this? Any help is much appreciated!

 ![Bildschirmfoto 2020-10-06 um 10.54.43](https://us1.discourse-cdn.com/elastic/original/3X/8/c/8c07518eb3138bcb41e0d74a4ce68accb025c78a.png)

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [October 6, 2020, 9:09am UTC](https://discuss.elastic.co/t/how-to-do-a-cohort-analysis-using-a-heatmap/251091/2 "2020-10-06T09:09:01Z")

</div>

Have a look at this [cohort plugin viz](https://github.com/synapticielfactory/kibana_cohort) for Kibana 7.8+  
Hope this can help

---

<div class="post-metadata">

**Author:** ![Max\_Handle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/max_handle/32/48133_2.png) [@Max\_Handle](https://discuss.elastic.co/u/Max_Handle)\
**Post date:** [October 6, 2020, 9:13am UTC](https://discuss.elastic.co/t/how-to-do-a-cohort-analysis-using-a-heatmap/251091/3 "2020-10-06T09:13:59Z")

</div>

Hi Yassine,  
thank you for your quick reply, unfortunately I am bound the functions provided in elastic cloud. So would there be also a workaround in this environment without plugins?

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [October 6, 2020, 9:17am UTC](https://discuss.elastic.co/t/how-to-do-a-cohort-analysis-using-a-heatmap/251091/4 "2020-10-06T09:17:14Z")

</div>

For each document in your dataset yur need :  
@timestamp : the datetime of the event  
first\_visit\_date : the datetime of the first event of the userId  
From these 2 fields you will be able to compute the number of days after the first event for evey user and that field can be used with first\_visit\_date date in the heatMap ...

---

<div class="post-metadata">

**Author:** ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)\
**Post date:** [October 6, 2020, 9:18am UTC](https://discuss.elastic.co/t/how-to-do-a-cohort-analysis-using-a-heatmap/251091/5 "2020-10-06T09:18:19Z")

</div>

Check also this [discussion](https://discuss.elastic.co/t/user-retention-analysis-in-kibana-cohorts/120733)

---

<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 3, 2020, 9:18am UTC](https://discuss.elastic.co/t/how-to-do-a-cohort-analysis-using-a-heatmap/251091/6 "2020-11-03T09:18:20Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
