您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關clickhouse數據模型中有序漏斗是什么,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
前言
假設我們已經得到了觸達支付購買的路徑有 “首頁->詳情頁->購買頁->支付“ 和 “搜索頁->詳情頁->購買頁->支付“ 兩個主要路徑,但是我們不清楚哪條路徑轉化率高,那么這個時候漏斗分析就派上用場了
windowFunnel(window)(timestamp, cond1, cond2, ..., condN)
# 創建一張用戶行為表,至少包含時間、事件、用戶idCREATE TABLE test.action( `uid` Int32, `event_type` String, `time` datetime)ENGINE = MergeTree()PARTITION BY uidORDER BY xxHash42(uid)SAMPLE BY xxHash42(uid)SETTINGS index_granularity = 8192
insert into action values(1,'瀏覽','2020-01-02 11:00:00');
insert into action values(1,'點擊','2020-01-02 11:10:00');
insert into action values(1,'下單','2020-01-02 11:20:00');
insert into action values(1,'支付','2020-01-02 11:30:00');
insert into action values(2,'下單','2020-01-02 11:00:00');
insert into action values(2,'支付','2020-01-02 11:10:00');
insert into action values(1,'瀏覽','2020-01-02 11:00:00');
insert into action values(3,'瀏覽','2020-01-02 11:20:00');
insert into action values(3,'點擊','2020-01-02 12:00:00');
insert into action values(4,'瀏覽','2020-01-02 11:50:00');
insert into action values(4,'點擊','2020-01-02 12:00:00');
insert into action values(5,'瀏覽','2020-01-02 11:50:00');
insert into action values(5,'點擊','2020-01-02 12:00:00');
insert into action values(5,'下單','2020-01-02 11:10:00');
insert into action values(6,'瀏覽','2020-01-02 11:50:00');
insert into action values(6,'點擊','2020-01-02 12:00:00');
insert into action values(6,'下單','2020-01-02 12:10:00');
SELECT
user_id,
windowFunnel(1800)(time, event_type = '瀏覽', event_type = '點擊', event_type = '下單', event_type = '支付') AS level
FROM
(
SELECT
time,
event_type,
uid AS user_id
FROM action
)
GROUP BY user_id
┌─user_id─┬─level─┐
│ 3 │ 1 │
│ 2 │ 0 │
│ 5 │ 2 │
│ 1 │ 4 │
│ 6 │ 3 │
└─────────┴───────┘
SELECT level_index,count(1) FROM( SELECT user_id, arrayWithConstant(level, 1) levels, arrayJoin(arrayEnumerate( levels )) level_index FROM ( SELECT user_id, windowFunnel(1800)( time, event_type = '瀏覽', event_type = '點擊' , event_type = '下單', event_type = '支付' ) AS level FROM ( SELECT time, event_type , uid as user_id FROM test.action WHERE toDate(time) = '2020-01-02' ) GROUP BY user_id ))group by level_indexORDER BY level_index
關于“clickhouse數據模型中有序漏斗是什么”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。