
1. 리텐션이란?
- 리텐션은 특정 날짜에 애플리케이션을 다시 방문(혹은 구매 등 특정 지표)한 사용자의 비율
- 즉, 재방문율, 잔존율과 동의어
- 여기서 특정 날짜 이전에 사용자와 이 애플리케이션 간의 잠재적인 상호 작용을 고려하지 않음
- 이러한 방법은 가장 널리 퍼져 있으며 응용 프로그램의 전반적인 유지 능력에 대한 좋은 아이디어를 제공
- 리텐션은 다음과 같이 표현이 가능
리텐션 비율=초기 코호트의 총 사용자 수지속적으로 활동 중인 사용자 수×100
2. 코호트 분석에서 리텐션 활용
- 코호트 분석은 장기적인 사용자 유지 패턴을 이해하고, 비즈니스와 제품 개선에 중요한 통찰을 제공하는 데 유용한 도구
2-1. 사용자 행동 분석
- 코호트 분석을 통해 시간이 지남에 따라 사용자 행동을 추적
- 예를 들어, 특정 기능이나 캠페인 도입 후 리텐션이 어떻게 변화하는지를 분석하여 어떤 변화가 사용자 유지에 긍정적 또는 부정적 영향을 미치는지 파악 가능
2-2. 제품 개선
- 리텐션 데이터를 분석함으로써 제품이나 서비스의 문제점을 발견하고 개선 가능
- 특정 시점에서 리텐션이 하락할 경우, 해당 시점에 변화를 분석하여 조치를 취할 수 있음
2-3. 마케팅 전략 평가
- 캠페인 후 리텐션 비율이 높아지면, 캠페인이 긍정적인 영향을 미쳤다는 것을 의미
2-4. 비즈니스 결정 지원
- 리텐션 데이터를 기반으로 비즈니스 전략을 조정
2-5. 고객 세분화
- 리텐션 분석을 통해 사용자의 행동 패턴을 이해하고, 다양한 세그먼트(세부 그룹)로 나누어 맞춤형 서비스를 제공할 수 있습니다.
3. 파이썬 예시 코드
using_usr_lst = users[users['created_at']>'2024-01-01']['id'].tolist()
using_order_data = orders[
(~orders['status'].isin(['Cancelled','Returned']))*
(orders['user_id'].isin(using_usr_lst))
]
using_order_data['order_dt'] = [i[:7] for i in using_order_data['created_at']]
using_order_data = using_order_data[['user_id','order_dt']]
using_order_data.head()

first_order_data = using_order_data.groupby('user_id')[['order_dt']].min().reset_index()
first_order_data.columns = ['user_id','first_order_dt']

merge_data = pd.merge(using_order_data, first_order_data, how='left', on='user_id')
merge_data.head()

cohorts = merge_data.groupby(['order_dt','first_order_dt'])[['user_id']].count().reset_index()
cohorts.columns = ['order_dt','first_order_dt','user_cnt']
cohorts = cohorts.sort_values(by=['first_order_dt','order_dt'])
each_period = cohorts["first_order_dt"].value_counts().sort_index()
cohortperiod = []
for x in each_period:
for y in range(x):
cohortperiod.append(y)
cohorts["order_dt"] = cohortperiod
cohorts = cohorts.set_index(["first_order_dt", "order_dt"])
cohorts = cohorts["user_cnt"].unstack(1)
cohorts.head()

user_retention = cohorts.divide(cohorts[0], axis=0)
user_retention

plt.figure(figsize=(12, 8))
plt.title("Cohort Analysis", fontsize=20)
sns.heatmap(user_retention, annot=True, fmt=".0%")
plt.show()
