某寶數(shù)據(jù)產(chǎn)品
每年年底我們都能收到某寶的一個觸達季蚂,回顧當(dāng)年我們的消費情況矩动,下面是我在WB上搜到的一個賬單信息鸿吆,只截取了部分,從回顧中我們能夠清晰的看到當(dāng)年消費情況需曾,以及一些我們連自己都想不到的一些消費數(shù)據(jù)。今天我們就來看看像這樣的數(shù)據(jù)產(chǎn)品祈远,我們是如何實現(xiàn)的呢呆万。
構(gòu)建數(shù)據(jù)產(chǎn)品流程
在實際工作中,想要實現(xiàn)像某寶的數(shù)據(jù)產(chǎn)品车份,我們主要有以下幾部分內(nèi)容谋减。如下圖中紅色的第一部分:
- 首先確定目標,我們這個數(shù)據(jù)產(chǎn)品為了干嘛扫沼,是提高活躍還是希望作為營銷工具提高我們核心指標出爹,比如銷量。
- 一旦確定了目標缎除,就需要進行產(chǎn)品的設(shè)計严就,就需要看藍色部分的設(shè)計圖,這部分主要是由運營同學(xué)來進行設(shè)計器罐,確定一些核心指標梢为。
- 品設(shè)計完成之后,我們需要考慮底層數(shù)據(jù)的加工轰坊,加工完成之后铸董,由研發(fā)同學(xué)進行調(diào)用,觸達給相應(yīng)的用戶衰倦。
- 最后袒炉,數(shù)據(jù)分析同學(xué)進行效果分析,此次活躍的效果如何樊零,在分析時我磁,需要注意的是孽文,我們?nèi)绾未_定是由這個活動帶來的活躍,最好是進行埋點夺艰,如果沒有埋點芋哭,那么,我們可以進行一些邏輯判斷郁副,比如减牺,至少這個用戶當(dāng)日第一次登錄是在我觸達之后,具體的邏輯判斷需要實際做的時候確定存谎,但是拔疚,建議埋點最好
構(gòu)建底層數(shù)據(jù)
一旦我們確定了具體的數(shù)據(jù)產(chǎn)品,接下來就是如何處理底層數(shù)據(jù)的問題了既荚。我們以一個具體的數(shù)據(jù)給大家講講該如何去實現(xiàn)稚失,下圖是我們具體的數(shù)據(jù)源:
通過這個數(shù)據(jù)源,我模擬了設(shè)計一個數(shù)據(jù)產(chǎn)品恰聘,如下:
這個數(shù)據(jù)產(chǎn)品主要分三部分:
- 第一部分是總述句各,加上每個月消費額的趨勢。
- 第二部分是按照城市的維度來看
- 第三部分是看用戶第一次購買的數(shù)據(jù)
通過上面的產(chǎn)品晴叨,我們可以知道具體的數(shù)據(jù)指標凿宾,但是如果研發(fā)在調(diào)用我們數(shù)據(jù)的時候,一般都是一個用戶一條數(shù)據(jù)兼蕊,所以初厚,我們需要在底層把用戶的數(shù)據(jù)加工成N個字段,以user_id為主鍵孙技,其他的所有數(shù)據(jù)都是json的格式存儲
具體SQL
select
cumu.Customer_ID,
parse_json('sum_sale',sum_sale,'sum_order_cnt',sum_order_cnt,'dis_city_cnt',dis_city_cnt,'dis_product_cnt',dis_product_cnt,'first_order_date',first_order_date,'first_city',first_city,'first_product_id',first_product_id,'max_sales_city',max_sales_city) as order_list
from
(##累計消息相關(guān)數(shù)據(jù)
select
Customer_ID,
sum(Sales) as sum_sale,##累計消費
count(distinct order_id) as sum_order_cnt,##累計下單
count(distinct city) as dis_city_cnt, ##不同的城市
count(distinct Product_ID) as dis_product_cnt ##不同的產(chǎn)品
from
chaoshi.order
where
year(order_date) = 2017
group by
Customer_ID
)cumu left join
(##第一次消費
select
Customer_ID,
Order_Date as first_order_date,
city as first_city,
Product_ID as first_product_id
from
(
select
Customer_ID,
Product_ID,
Order_Date,
city,
row_number() over(partition by Customer_ID order by Order_Date asc) as num
from
chaoshi.order
where
year(order_date) = 2017
)a
where
num = 1
)f on cumu.Customer_ID = f.Customer_ID
left join
(## 消費最多的城市
select
Customer_ID,
city,
sum_sales_city as max_sales_city
from
(
select
Customer_ID,
city,
sum_sales_city,
row_number() over(partition by Customer_ID order by sum_sales_city desc) as num
from
(
select
Customer_ID,
city,
sum(sales) as sum_sales_city
from
chaoshi.order
where
year(order_date) = 2017
group by
Customer_ID,
City
)a
)b
where
num = 1
)cy on cumu.Customer_ID = cy.Customer_ID
星星詳析
上面我們得到了一個用戶的一條數(shù)據(jù)惧所,但是我們就是取到了累計消費、累計訂單绪杏、分布的城市數(shù)下愈、購買了不同的產(chǎn)品量、第一個訂單時間蕾久、第一個訂單城市势似、第一個訂單的產(chǎn)品以及訂單量最多的城市。
最后僧著,通過parse_json履因,把這些字段整合到一個json的字典中。
但是盹愚,我們有沒有發(fā)現(xiàn)還有一部分內(nèi)容栅迄,就是每個月的消費量趨勢沒有處理。接下來皆怕,我們單獨說說這一部分的內(nèi)容毅舆,這部分特殊點在于西篓,每個用戶并不是對應(yīng)一條數(shù)據(jù)。我們需要其他的函數(shù)來處理憋活,具體如下:
select
Customer_ID,
concat('[',concat_ws(',',collect_list(json)),']') as month_list
from
(
select
Customer_ID,
parse_json('order_month',order_month,'sum_sales_month',sum_sales_month) as json
from
(##每個月消費數(shù)據(jù)
select
Customer_ID,
month(order_date) as order_month,
sum(sales) as sum_sales_month
from
chaoshi.order
where
year(order_date) = 2017
group by
Customer_ID,
month(order_date)
)m
)aa
group by
Customer_ID
我們通過concat_ws和collect_list以及concat岂津,把多個json處理成一個列表的形式,這樣還是一個用戶一條數(shù)據(jù)悦即,便于研發(fā)調(diào)用吮成,最后,這兩個SQL再關(guān)聯(lián)辜梳,取出
Customer_ID/order_list/month_list形成三個字段粱甫,具體如下:
Customer_ID | order_list | month_list |
---|---|---|
235543323 | {'sum_sale':23545,'sum_order_cnt':223,'dis_city_cnt':3,'dis_product_cnt':78,'first_order_date':'2017-01-03','first_city':'北京','first_product_id',3535,'max_sales_city':'北京'} | [{'1':234},{'2',464},...] |
這樣,我們就構(gòu)建了整個數(shù)據(jù)產(chǎn)品的底層數(shù)據(jù)部分作瞄。
接下就是運營同學(xué)直接就觸達我們的目標用戶了魔种,觸達完了之后,就需要具體分析這個數(shù)據(jù)產(chǎn)品的效果了粉洼。關(guān)于如何分析活動的效果,這里我們不做具體的說明叶摄,后面會有專門的文章去介紹