250x250
Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

데이터 놀이터

코호트 분석 본문

마케팅

코호트 분석

jjjk84 2023. 9. 9. 23:49
728x90

1. 코호트 분석 정의

 

코호트는 특정 기간 동안 공통된 특성이나 경험을 가지는 사용자 집단을 말한다.

코호트 분석은 이러한 집단을 그룹으로 나눠 지표별로 수치화한 뒤 시간의 순서대로 분석하는 기법을 말한다. 

그룹을 나누는 기준은 도메인, 비지니스 상황에 따라 상이하다. 사용자가 세션을 시작한 날이 될 수도 있고, 사용자가 첫구매를 한 날일 수도 있다. 기준에 따라 한 사용자가 다수의 코호트 그룹에 속할 수도 있다.

분석 내용 또한 구매액, 리텐션 등 다양하게 선택할 수 있다.

 

2. 코호트 차트 그리기

구글 애널리틱스나 어도비 애널리틱스의 코호트 분석 기능을 활용하면, 자동으로 사용자 특성의 정의하고 특정 기간 내 사용자 행동을 지표 별로 분석할 수 있다.

python으로 코호트 차트를 그리기 위해서는 seaborn의 heatmap 기능을 활용하면 된다.

 

예시 코드

def cohort (df, title):
    # 분석 대상 구매 내역
    temp = transaction_new[transaction_new['customer_id'].isin(df['customer_id'].unique())][['customer_id', 'created_at']]
    
    # 프로모션 첫번째 이용일
    first_use = df.groupby('customer_id', as_index=False)['created_at'].min().reset_index(drop=True)
    first_use['created_at'] = first_use['created_at'].dt.strftime('%Y-%m')
    first_use.rename({'created_at' : 'first_use'}, axis=1, inplace=True)
    
    # 데이터 프레임 합치기
    temp = temp.merge(first_use, how='left', on='customer_id')
    temp['created_at'] = temp['created_at'].dt.strftime('%Y-%m')
    
    temp['first_use'] = pd.to_datetime(temp['first_use']).dt.to_period('M')
    temp['created_at'] = pd.to_datetime(temp['created_at']).dt.to_period('M')
    temp = temp[temp['first_use'] <= temp['created_at']]

    # 코호트 분석을 위한 데이터 프레임 만들기
    co = temp.groupby(['first_use', 'created_at'], as_index=False).customer_id.nunique()
    co.rename({'customer_id': 'total_users'}, axis = 1, inplace = True)

    co['cohort_period'] = (co['created_at'] - co['first_use']).map(lambda t: t.n)
  
    
    # 재구매율 구하기
    co_retention = co.set_index(['first_use', 'cohort_period'])
    co_retention = co_retention['total_users'].unstack(1)
    retention = co_retention.div(co_retention[0],axis = 0)
    
    plt.figure(figsize=(12, 8))
    plt.title(title, fontsize=19)
    plt.rcParams['font.family'] = 'Apple SD Gothic Neo'
    sns.heatmap(retention, annot=True, fmt='.0%')
    plt.show()

 

3. 코호트 차트 해석

코호트 차트가 처음 볼때 헷갈릴 수도 있으나, 코호트 기간의 뜻과 집단을 나눈 것을 명확히 인지하고 있다면 그리 어렵지 않다.

 

예를 들어 이 코호트 차트를 세로로 해석한다면, 각 날짜 별로 유입된 유저들의 코호트 기간(하루, 이틀...) 별 리텐션을 해석하는 것이다.

 

반면에 대각선으로 본다면, 분석하고자 하는 시점을 정하고 코호트 집단 간 비교를 하는 것이다.

 

출처 : https://velog.io/@tyhlife/%EB%A6%AC%ED%85%90%EC%85%98Retion%EA%B3%BC-%EC%BD%94%ED%98%B8%ED%8A%B8-%EB%B6%84%EC%84%9D-Cohort-Analysis

728x90

'마케팅' 카테고리의 다른 글

리텐션 SQL 쿼리문 짜기  (0) 2023.10.13
리텐션 차트와 커브  (0) 2023.10.08
사용자 고착도 (Stickiness)  (0) 2023.10.08
리텐션  (0) 2023.10.07
데이터 마케팅과 그로스 해킹  (0) 2023.08.03