Merged PR 2441: KPIs - Customer Segmentation based on listings

This PR creates a new model int_core__mtd_accommodation_segmentation that provides the customer segments based on listing activity:
- 0
- 1-5
- 6-20
- 21-60
- 61+

For end of April 2024, the volume distribution on number of deals and total listings booked is:
![image.png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/2441/attachments/image.png)
For information, I estimate that around 3% of listings with bookings are missed, according to the data displayed in the KPIs for 30th April 2024. This is because we enforce deal-based categorisation (same happens with the deal view, anyway)

Related work items: #19325
This commit is contained in:
Oriol Roqué Paniagua 2024-07-30 13:21:08 +00:00
parent b79df1b42e
commit 65ebd8c2d2
2 changed files with 99 additions and 0 deletions

View file

@ -0,0 +1,42 @@
{{ config(materialized="table", unique_key=["date", "id_deal"]) }}
with
int_core__mtd_accommodation_lifecycle as (
select * from {{ ref("int_core__mtd_accommodation_lifecycle") }}
),
int_core__unique_accommodation_to_user as (
select * from {{ ref("int_core__unique_accommodation_to_user") }}
),
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}),
active_accommodations_per_deal as (
select
al.date,
uu.id_deal,
sum(
case when al.has_been_booked_within_last_12_months then 1 else 0 end
) as accommodations_booked_in_12_months
from int_core__mtd_accommodation_lifecycle al
inner join
int_core__unique_accommodation_to_user atu
on al.id_accommodation = atu.id_accommodation
inner join int_core__unified_user uu on uu.id_user = atu.id_user_owner
where uu.id_deal is not null
group by 1, 2
)
select
date,
id_deal,
case
when accommodations_booked_in_12_months = 0
then '0'
when accommodations_booked_in_12_months between 1 and 5
then '1-5'
when accommodations_booked_in_12_months between 6 and 20
then '6-20'
when accommodations_booked_in_12_months between 21 and 60
then '21-60'
when accommodations_booked_in_12_months >= 61
then '61+'
end as active_accommodations_per_deal_segmentation,
accommodations_booked_in_12_months
from active_accommodations_per_deal

View file

@ -753,6 +753,63 @@ models:
data_type: boolean
description: If the listing has had a booking created in the past 12 months.
- name: int_core__mtd_accommodation_segmentation
description: |
This model contains the historic information regarding the customer segmentation based on active accommodations,
also known as listings. This model depends on the int_core__mtd_accommodation_lifecycle, thus the time granularity
is the same as for any mtd model.
The segmentation is applied at deal level, not at user host level. This has the drawback that hosts without a
deal assigned won't be considered in this segmentation. However, it correctly categorises customers based on the
number of listings across the different user hosts each deal can have.
The segmentation is available in the field active_accommodations_per_deal_segmentation. It considers listings that
have been booked within the last 12 months. Thus, it means it only considers the lifecycle states of
03-First Time Booked, 04-Active and 07-Reactivated. The segments are the following:
- '0'
- '1-5'
- '6-20'
- '21-60'
- '61+'
These segments are inspired from the ones RevOps team uses, but the associated deals and listings volume will differ
since the listing activity logic considered is different.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- date
- id_deal
columns:
- name: date
data_type: date
description: The date for the month-to-date. Information is inclusive to the date displayed.
tests:
- not_null
- name: id_deal
data_type: character varying
description: Id of the deal associated to the host.
tests:
- not_null
- name: active_accommodations_per_deal_segmentation
data_type: character varying
description: The segmentation based on the number of listings booked in the last 12 months.
tests:
- not_null
- accepted_values:
values:
- '0'
- '1-5'
- '6-20'
- '21-60'
- '61+'
- name: accommodations_booked_in_12_months
data_type: integer
description: Informative field of the actual number of listings booked in the last 12 months
- name: int_core__mtd_deal_lifecycle
description: |
This model contains the historic information regarding the lifecycle of hosts, at deal level.