實時專案 漏斗分析

2021-10-13 21:59:39 字數 2593 閱讀 3156

需求:

接下來我們用sql實現這個需求:

我們來查詢 20201227到20201230 事件範圍內,並且視窗時間是3天的漏斗

注意:我們這裡資料就三天,所以視窗期也就是不用判斷,但是我們以後可能會拿到n天資料,所以要加視窗期判斷

sql實現:

-- 分析sql,首先我們可以先把每乙個事件的資料按照條件查詢出來,然後在將每乙個事件中的時間拿到,進行關聯查詢,通過時間進行判斷該事件是否在視窗期以內,並且還要和上乙個事件判斷,一定要大於它

-- 拿到三天內每乙個事件資料

with t1 as

(select

distinct_id,

ctime,

event

from ods_db_news.event

where event=

'signup'

and format_datetime(from_unixtime(ctime/

1000),

'yyyymmdd'

)>=

'20201201'

and format_datetime(from_unixtime(ctime/

1000),

'yyyymmdd'

)<=

'20201230'),

t2 as

(select

distinct_id,

ctime,

event

from ods_db_news.event

where event=

and element_page=

'新聞列表頁'

and format_datetime(from_unixtime(ctime/

1000),

'yyyymmdd'

)>=

'20201201'

and format_datetime(from_unixtime(ctime/

1000),

'yyyymmdd'

)<=

'20201230'),

t3 as

(select

distinct_id,

ctime,

event

from ods_db_news.event

where event=

and element_page=

'內容詳情頁'

and format_datetime(from_unixtime(ctime/

1000),

'yyyymmdd'

)>=

'20201201'

and format_datetime(from_unixtime(ctime/

1000),

'yyyymmdd'

)<=

'20201230'),

t4 as

(select

distinct_id,

ctime,

event

from ods_db_news.event

where event=

'newsaction'

and action_type=

and format_datetime(from_unixtime(ctime/

1000),

'yyyymmdd'

)>=

'20201201'

and format_datetime(from_unixtime(ctime/

1000),

'yyyymmdd'

)<=

'20201230'

)select

count

(distinct t1.distinct_id) step1,

count

(distinct t2.distinct_id) step2,

count

(distinct t3.distinct_id) step3,

count

(distinct t4.distinct_id) step4

from t1

left

join t2

on t1.distinct_id=t2.distinct_id

and t1.ctime86400*3

*1000

left

join t3

on t2.distinct_id=t3.distinct_id

and t2.ctime86400*3

*1000

left

join t4

on t3.distinct_id=t4.distinct_id

and t3.ctime86400*3

*1000

;

結果:

執行上述查詢可以看到如下類似結果

step1 | step2 | step3 | step4

-------±------±------±------

3154 | 79 | 2 | 1

代表著我們的漏斗的每一步的人數

資料分析之漏斗模型

提起漏斗,讓我首先想到的是它的 形狀 圓錐形的 頂部寬底部窄 其次是它的 功能 過濾雜質,如生了蟲的白面 炸過豆腐的油等。形狀如下圖形狀才能夠有效的行使它的功能職責 過濾。功能過濾雜質 生了蟲的白面 小時候的農村,夏天雨水較多,家裡比較潮濕,缸裡的面經常會有蟲子光顧。那個時候物質匱乏,不捨的扔掉,會...

資料分析框架之AARRR漏斗模型

aarrr模型是運營裡面乙個非常有名的使用者分析模型,也是乙個典型的漏斗模型,前段時間工作上寫的分析材料裡面也提到了這個模型,這個模型也可以作為資料分析的框架,這裡結合了網上的一些參考資料,總結了模型中可能涉及到各項分析指標和分析方法。aarrr模型將資料分析分為了5個部分,而aarrr模型在使用者...

實時專案概述

離線計算就是在計算開始前已知所有輸入資料,輸入資料不會產生變化,一般計算量級比較大,計算時間相對較長。例如月初對上月整月,凌晨對前一整天的資料進行計算,最經典的就是hadoop的 mr 方式。一般是根據前一日 月的資料生成報表,雖然統計的指標報表繁多,但是時效性不高。輸入資料是可以序列化的方式乙個個...