第七阶段 数据分析应用案例(有板书).pdf

指标体系的能够带来的便利:

  • 业务、意识层面:
    • 更加清晰的业务认识、从整个业务层面去看待问题 ,有宏观的认识。能够更好的定位于问题有关的业务部门,便于我们协同处理问题。
  • 数据层面:
    • 能够对指标计算逻辑有清晰认识,能够方便我们定位数据计算的错误。

如何解决问题

  1. 确定业务目标
    • 从业务目标去分析额问题, 跳出问题本身
  2. 将目标拆解成详细问题
    • 拆解问题之后,能够分析我们现有问题的位置,对现有问题的有关系的问题或者是上下游的问题会有一个比较清楚的认知,对我们问题的形成有一个系统的认知。
  3. 对问题做优先级排序
    • 对问题的重要程度、紧急程度、解决问题的投入成本来进行排序。
  4. 制定问题解决方案
    • 对确定优先级之后的问题,指定解决方案,做成可以落地的方案
  5. 搜集数据分析重要问题
    • 搜集历史及数据分析方案可行性
    • 提前布置监控体系,监控方案运行效果
  6. 汇总研究成果
    • 对现有方案作总结,分析方案效果,验证方案的有效性,为项目汇报准备论据。
  7. 梳理论据逻辑,形成报告
    • 将准备的论据按照业务逻辑梳理,形成案例报告。
  8. 复盘
    • 在报告汇报之后需要收集各方反馈,对项目做进一步复盘。

目标确认与拆解

运用解决问题思路来达到领导要求的目标;主要运用前四点,从确定目标到解决方案。

通过历史统计数据得出现在的销售额和销售预期目标。

目标:根据领导要求9月的任务为8月的70%。

目标拆解:AARRR->ARARR

  • 目标是提升转化
  • 拉新、裂变、激活、留存、转化

一个产品如果久久体验不到核心功能,那么用户流失的就越快,从注册开始就得优化产品的使用路径。

目标拆解的原则,使用MECE法则,相互独立,完全穷尽。

教育专项问题解决思路

  1. select
  2. A.date,
  3. count(distinct A.user_id) as new_user,
  4. count(distinct T_Start.user_id) as pay_new_user,
  5. count(distinct T_Start.user_id) / count(distinct A.user_id)
  6. from
  7. (
  8. select
  9. date,
  10. user_id
  11. from
  12. event_ok
  13. where
  14. `$is_first_day` = 1
  15. and EVENT = '$AppStart'
  16. group by
  17. date,
  18. user_id
  19. ) as A
  20. inner join (
  21. select
  22. date,
  23. user_id
  24. from
  25. event_ok
  26. where
  27. EVENT = 'ReceiveVipFreely'
  28. and share_user_id is not null
  29. ) as B on A.date = B.date
  30. and A.user_id = B.user_id
  31. left join (
  32. select
  33. date,
  34. user_id
  35. from
  36. event_ok
  37. where
  38. EVENT = 'PayOrderSucceed'
  39. and actual_amount > 200
  40. group by
  41. date,
  42. user_id
  43. ) as T_Start on A.user_id = T_Start.user_id
  44. and T_Start.Date > A.date
  45. and DATE_SUB(T_Start.Date, Interval 14 DAY) <= A.date
  46. where
  47. A.Date in('2020-08-17')
  48. group by
  49. A.date;

运营活动效果分析

汇报阶段,一般是三个阶段但是这个时候是四个阶段。

实际操作,需要先执行
image.png

  1. #配置内部内存临时表的大小
  2. SET GLOBAL tmp_table_size =1024*1024*1024*2;
  3. #配置内存分配大小
  4. SET GLOBAL innodb_buffer_pool_size=67108864;
  5. set global log_bin_trust_function_creators=TRUE;
  6. DROP FUNCTION IF EXISTS insert_拉新;
  7. DROP FUNCTION IF EXISTS insert_下载渠道付费转化率;
  8. DROP FUNCTION IF EXISTS insert_用户活跃留存;
  9. DROP TABLE IF EXISTS temp_riqi;
  10. # 获得埋点数据日期列表
  11. create table temp_riqi
  12. select date from event_ok group by date
  13. order by date;
  14. # 生成插入拉新数据自定义函数
  15. CREATE FUNCTION insert_拉新(riqi Date) RETURNS int
  16. BEGIN
  17. DELETE FROM 用户拉新 where install_date in (DATE_SUB(riqi, Interval 1 DAY),DATE_SUB(riqi, Interval 7 DAY),DATE_SUB(riqi, Interval 14 DAY));
  18. insert 用户拉新
  19. select *,
  20. sum(u_cnt) over( PARTITION by install_date) as u_cnt_total,
  21. sum(retention_u_cnt) over( PARTITION by install_date) as retention_u_cnt_total,
  22. if(sum(u_cnt) over( PARTITION by install_date)=0,0,sum(retention_u_cnt) over( PARTITION by install_date)/sum(u_cnt) over( PARTITION by install_date)) as rention_pp_modi,
  23. sum(retention_u_cnt_7) over( PARTITION by install_date) as retention_u_cnt_total_7,
  24. if(sum(u_cnt) over( PARTITION by install_date)=0,0,sum(retention_u_cnt_7) over( PARTITION by install_date)/sum(u_cnt) over( PARTITION by install_date)) as rention_pp_modi_7,
  25. sum(retention_u_cnt_14) over( PARTITION by install_date) as retention_u_cnt_total_14,
  26. if(sum(u_cnt) over( PARTITION by install_date)=0,0,sum(retention_u_cnt_14) over( PARTITION by install_date)/sum(u_cnt) over( PARTITION by install_date)) as rention_pp_modi_14
  27. from(
  28. select install_date,downloadchannel,count(distinct user_id) as u_cnt,
  29. COUNT(distinct if(DATEDIFF(action_date,install_date)=1,user_id,Null)) as retention_u_cnt,
  30. if(count(distinct user_id) =0,0,COUNT(distinct if(DATEDIFF(action_date,install_date)=1,user_id,Null))/ count(distinct user_id)) as rention_pp,
  31. COUNT(distinct if(DATEDIFF(action_date,install_date)=7,user_id,Null)) as retention_u_cnt_7,
  32. if(count(distinct user_id)=0,0,COUNT(distinct if(DATEDIFF(action_date,install_date)=7,user_id,Null)) / count(distinct user_id)) as rention_pp_7,
  33. COUNT(distinct if(DATEDIFF(action_date,install_date)=14,user_id,Null)) as retention_u_cnt_14,
  34. if(count(distinct user_id)=0,0,COUNT(distinct if(DATEDIFF(action_date,install_date)=14,user_id,Null))/count(distinct user_id)) as rention_pp_14
  35. from(
  36. SELECT distinct T_Install.user_id,
  37. T_Install.downloadchannel, T_Install.date as install_date, T_Start.Date action_date
  38. from (
  39. select * from event_ok where `event` = 'AppInstall'
  40. -- 时间字段
  41. and date in (riqi,DATE_SUB(riqi, Interval 1 DAY),DATE_SUB(riqi, Interval 7 DAY),DATE_SUB(riqi, Interval 14 DAY)) ) as T_Install -- 待补日期
  42. left join (
  43. select * from event_ok where `event` = '$AppStart'
  44. -- 时间字段
  45. and date >= DATE_SUB(riqi, Interval 14 DAY) and date<= riqi) as T_Start -- 待补日期
  46. on T_Install.user_id = T_Start.user_id and
  47. ( DATE_SUB(T_Start.Date, Interval 1 DAY) = T_Install.date or DATE_SUB(T_Start.Date, Interval 7 DAY) = T_Install.date or
  48. DATE_SUB(T_Start.Date, Interval 14 DAY) = T_Install.date)) as T_Install_Start
  49. group by Install_date,downloadchannel) as add_date_sta;
  50. RETURN ROW_COUNT();
  51. END ;
  52. #调用函数插入8月15号以后拉新数据
  53. select insert_拉新(date) from temp_riqi where date >'2020-08-15';
  54. # 生成插入用户活跃留存数据自定义函数
  55. CREATE FUNCTION insert_用户活跃留存(riqi Date) RETURNS int
  56. begin
  57. delete from 用户活跃_用户活跃留存
  58. where install_date in(DATE_SUB(riqi, Interval 1 DAY),DATE_SUB(riqi, Interval 7 DAY),DATE_SUB(riqi, Interval 14 DAY));
  59. insert 用户活跃_用户活跃留存
  60. select install_date,count(distinct user_id) as dau,
  61. count(distinct case when first_flag = 1 then user_id else null end) as first_dau,
  62. if(count(distinct user_id) =0,0,count(distinct case when first_flag = 1 then user_id else null end)/count(distinct user_id)) as first_PP,
  63. COUNT(distinct if(DATEDIFF(action_date,install_date)=1,user_id,Null)) as retention_dau_1,
  64. if(count(distinct user_id)=0,0,COUNT(distinct if(DATEDIFF(action_date,install_date)=1,user_id,Null))/ count(distinct user_id)) as retention_pp_1,
  65. COUNT(distinct if(DATEDIFF(action_date,install_date)=7,user_id,Null)) as retention_dau_7,
  66. if(count(distinct user_id) =0,0,COUNT(distinct if(DATEDIFF(action_date,install_date)=7,user_id,Null)) / count(distinct user_id)) as rention_pp_7,
  67. COUNT(distinct if(DATEDIFF(action_date,install_date)=14,user_id,Null)) as retention_dau_14,
  68. if(count(distinct user_id) =0,0,COUNT(distinct if(DATEDIFF(action_date,install_date)=14,user_id,Null))/count(distinct user_id)) as rention_pp_14
  69. from(
  70. SELECT distinct T_Action.user_id,T_Action.date as install_date, T_Action.$is_first_day as first_flag,T_Start.Date action_date
  71. from (
  72. select user_id,$is_first_day,Date from event_ok where `event` = '$AppStart'
  73. -- 时间字段
  74. and date in (riqi,DATE_SUB(riqi, Interval 1 DAY),DATE_SUB(riqi, Interval 7 DAY),DATE_SUB(riqi, Interval 14 DAY)) -- 待补日期
  75. group by user_id,$is_first_day,Date
  76. ) as T_Action
  77. left join (
  78. select * from event_ok where `event` = '$AppStart'
  79. -- 时间字段
  80. and date >= DATE_SUB(riqi, Interval 14 DAY) and date<= riqi) as T_Start -- 待补日期 ,第二个日期为第一个日期加14
  81. on T_Action.user_id = T_Start.user_id and
  82. ( DATE_SUB(T_Start.Date, Interval 1 DAY) = T_Action.date or DATE_SUB(T_Start.Date, Interval 7 DAY) = T_Action.date or
  83. DATE_SUB(T_Start.Date, Interval 14 DAY) = T_Action.date)) as T_Action_Start
  84. group by Install_date;
  85. RETURN ROW_COUNT();
  86. END ;
  87. #调用函数插入8月15号以后用户活跃留存数据
  88. select insert_用户活跃留存(date) from temp_riqi where date >'2020-08-15';
  89. #补充8月15日之后的数据到用户在线时长表
  90. insert 用户活跃_用户在线时长
  91. select
  92. Install_date,
  93. count(distinct T_Action.user_id) as dau,
  94. sum(duration) as total_duration,
  95. if(count(distinct T_Action.user_id)=0,0,sum(duration)/count(distinct T_Action.user_id)) as duration_mean
  96. from
  97. (
  98. select user_id,Date as install_date from event_ok
  99. where `event` = '$AppStart'
  100. -- 时间字段
  101. and date > '2020-08-15' -- 待补日期,当天日期
  102. group by user_id,Date
  103. ) as T_Action
  104. left join
  105. (
  106. select user_id, date as end_date, sum($event_duration) as duration from event_ok
  107. where `event` = '$AppEnd'
  108. -- 时间字段
  109. and date > '2020-08-15' -- 待补日期,当天日期
  110. group by user_id, date
  111. ) as T_end
  112. on T_Action.user_id = T_end.user_id and install_date = end_date
  113. group by Install_date;
  114. #补充不为8月15的数据到总收入统计
  115. insert 产品收入_总收入统计
  116. select
  117. Install_date,
  118. count(distinct user_id) as pay_user,
  119. sum(actual_amount_total) as total_amount,
  120. if(count(distinct user_id) =0,0,sum(actual_amount_total)/count(distinct user_id)) as amount_mean,
  121. #训练营
  122. count(distinct case when income_type =1 then user_id else null end) as pay_user_xly,
  123. sum(case when income_type =1 then actual_amount_total else 0 end) as total_amount_xly,
  124. if(count(distinct case when income_type =1 then user_id else null end) =0,0,coalesce(sum(case when income_type =1 then actual_amount_total else 0 end)/count(distinct case when income_type =1 then user_id else null end),0)) as amount_mean_xly,
  125. #专栏
  126. count(distinct case when income_type =2 then user_id else null end) as pay_user_zl,
  127. sum(case when income_type =2 then actual_amount_total else 0 end) as total_amount_zl,
  128. if(count(distinct case when income_type =2 then user_id else null end)=0,0,coalesce(sum(case when income_type =2 then actual_amount_total else 0 end)/count(distinct case when income_type =2 then user_id else null end),0)) as amount_mean_zl,
  129. #会员
  130. count(distinct case when income_type =3 then user_id else null end) as pay_user_member,
  131. sum(case when income_type =3 then actual_amount_total else 0 end) as total_amount_member,
  132. if(count(distinct case when income_type =3 then user_id else null end) <> 0,sum(case when income_type =3 then actual_amount_total else 0 end)/count(distinct case when income_type =3 then user_id else null end),0) as amount_mean_member
  133. from
  134. (
  135. select
  136. user_id,
  137. date as Install_date,
  138. case when actual_amount > 200 and (order_type = '课程' or order_type is null) then 1
  139. when actual_amount >=0 and actual_amount <= 200 and (order_type = '课程' or order_type is null) then 2
  140. when order_type = '会员' then 3
  141. else -1 end as income_type,
  142. sum(actual_amount) as actual_amount_total
  143. from event_ok
  144. where event = 'PayOrderSucceed'
  145. -- 时间字段
  146. and date != '2020-08-15' -- 待补时间,当天日期
  147. group by 1,3,2
  148. ) PayOrderSucceed
  149. where actual_amount_total>0
  150. group by
  151. Install_date
  152. order by
  153. Install_date;
  154. ##补充不为8月15的数据到训练营收入统计
  155. insert 产品收入_训练营收入统计
  156. -- 神策数据
  157. select
  158. exp.*,
  159. if(exp.exp_xly_cnt =0,0,exp.exp_xly_pv/exp.exp_xly_cnt) as exp_xly_step_mean,
  160. clk.clk_xly_cnt,
  161. clk.clk_xly_pv,
  162. -- 点击率
  163. if(exp.exp_xly_cnt=0,0,clk.clk_xly_cnt/exp.exp_xly_cnt) as xly_ctr_uv,
  164. -- app 用户数,点击率
  165. exp_1.xly_sx_cnt_app,
  166. if(clk.clk_xly_cnt=0,0,exp_1.xly_sx_cnt_app/clk.clk_xly_cnt) as clk2sx_pp,
  167. exp_1.xly_sx_cnt,
  168. clk_1.xly_appointment_cnt,
  169. if(exp_1.xly_sx_cnt=0,0,clk_1.xly_appointment_cnt/exp_1.xly_sx_cnt) as sx2appointment_pp,
  170. pay.pay_user_xly_cnt,
  171. if(clk_1.xly_appointment_cnt=0,0,pay.pay_user_xly_cnt/clk_1.xly_appointment_cnt) as clk2pay_rate_xly,
  172. pay.pay_xly_order_amount,
  173. if(pay.pay_user_xly_cnt =0,0,pay.pay_xly_order_amount/pay.pay_user_xly_cnt) as xly_arppu,
  174. if(exp_1.xly_sx_cnt =0,0,pay.pay_xly_order_amount/exp_1.xly_sx_cnt) as value_per_sx_uv_xly
  175. from
  176. (
  177. select date,count(distinct user_id) as exp_xly_cnt,count(1) as exp_xly_pv
  178. from event_ok
  179. -- 运营位曝光 新增埋点
  180. where event = 'ViewOperatingPosition'
  181. and operating_type='训练营'
  182. -- 时间字段
  183. and date > '2020-08-15' -- 待补时间,当天日期
  184. group by date
  185. ) exp
  186. left outer join
  187. (
  188. select date, count(distinct user_id) as clk_xly_cnt, count(user_id) as clk_xly_pv
  189. from event_ok
  190. -- 运营位点击
  191. where event = 'ClickOperatingPosition' and operating_type='训练营'
  192. -- 时间字段
  193. and date > '2020-08-15' -- 待补时间,当天日期
  194. group by date
  195. ) clk
  196. on exp.date = clk.date
  197. -- 训练营商详用户数
  198. left join
  199. (
  200. select date, count(distinct user_id) as xly_sx_cnt,
  201. count(distinct case when platform_type in ('Android','iOS') then user_id else null end) as xly_sx_cnt_app
  202. from event_ok
  203. where event = 'WebView'
  204. and page_id in ('1pb3','1pb4','1pu4','1pu5','1pxi','1qb3','1qea','1qeb','1qg1','1qhg','1qjk','1qph','1qzq')
  205. -- 时间字段
  206. and date > '2020-08-15' -- 待补时间,当天日期
  207. group by
  208. date
  209. ) exp_1
  210. on exp.date = exp_1.date
  211. -- 训练营预约用户数(报名)
  212. left outer join
  213. (
  214. select date,count(distinct user_id) as xly_appointment_cnt
  215. from event_ok
  216. -- web点击
  217. where event = 'WebButtonClick'
  218. and page_id in ('1pb3','1pb4','1pu4','1pu5','1pxi','1qb3','1qea','1qeb','1qg1','1qhg','1qjk','1qph','1qzq')
  219. -- 时间字段
  220. and date != '2020-08-15' -- 待补时间,当天日期
  221. group by date
  222. ) clk_1
  223. on clk.date = clk_1.date
  224. -- 训练营付费
  225. left outer join
  226. (
  227. select date , count(distinct user_id) as pay_user_xly_cnt, sum(actual_amount) as pay_xly_order_amount
  228. from event_ok
  229. -- 支付成功
  230. where event = 'PayOrderSucceed'
  231. and actual_amount > 200
  232. and order_type != '会员'
  233. -- 时间字段
  234. and date != '2020-08-15' -- 待补时间,当天日期
  235. group by date
  236. ) pay
  237. on exp.date = pay.date
  238. order by exp.date;
  239. #向专栏收入统计插入日期不为8月15的数据
  240. insert 产品收入_专栏收入统计
  241. select
  242. vop.date,
  243. exp_zl_cnt,
  244. exp_zl_pv,
  245. if(exp_zl_cnt=0,0,exp_zl_pv/exp_zl_cnt) as exp_zl_step_mean,
  246. clk_zl_cnt,
  247. clk_zl_pv,
  248. if(exp_zl_cnt=0,0,clk_zl_cnt/exp_zl_cnt) as zl_ctr_uv,
  249. zl_sx_uv,
  250. zl_sx_uv_app,
  251. -- t21.zl_sx_uv_app/t2.clk_zl_cnt as clk2open_pp,
  252. zl_create_order_cnt,
  253. if(zl_sx_uv=0,0,zl_create_order_cnt/zl_sx_uv) as open2create_order_pp,
  254. pay_user_zl_cnt,
  255. if(zl_create_order_cnt=0,0,pay_user_zl_cnt/zl_create_order_cnt) as clk2pay_rate_zl,
  256. pay_zl_order_amount,
  257. if(pay_user_zl_cnt=0,0,pay_zl_order_amount/pay_user_zl_cnt) as zl_arppu,
  258. if(zl_sx_uv=0,0,pay_zl_order_amount/zl_sx_uv) as value_per_sx_uv_zl
  259. from
  260. (
  261. select date, count(distinct user_id) as exp_zl_cnt, count(1) as exp_zl_pv
  262. from event_ok
  263. -- 运营位曝光
  264. where event = 'ViewOperatingPosition' and operating_type='课程列表页'
  265. -- 时间字段
  266. and date != '2020-08-15' -- 待补日期,当天日期
  267. group by date
  268. ) vop
  269. left join
  270. (
  271. select date , count(distinct user_id) as clk_zl_cnt,count(user_id) as clk_zl_pv
  272. from event_ok
  273. where event = 'ClickOperatingPosition' and operating_type='课程列表页'
  274. -- 时间字段
  275. and date != '2020-08-15' -- 待补日期,当天日期
  276. group by date
  277. ) cop
  278. on vop.date = cop.date
  279. left join
  280. (
  281. select
  282. date,count(distinct user_id) as zl_sx_uv,
  283. count(distinct case when platform_type in ('Android','iOS') then user_id else null end) as zl_sx_uv_app
  284. from event_ok
  285. -- 浏览售前课程详情页
  286. where event = 'ViewCourseDetail'
  287. -- 时间字段
  288. and date != '2020-08-15' -- 待补日期,当天日期
  289. group by date
  290. ) vcd
  291. on vop.date = vcd.date
  292. left join
  293. (
  294. select date , count(distinct user_id) as zl_create_order_cnt
  295. from event_ok
  296. -- 创建订单
  297. where event = 'CreateOrder' and order_amount < 200
  298. -- 时间字段
  299. and date != '2020-08-15' -- 待补日期,当天日期
  300. group by date
  301. ) co
  302. on vop.date = co.date
  303. -- 专栏付费用户
  304. left outer join
  305. (
  306. select date, count(distinct user_id) as pay_user_zl_cnt, sum(actual_amount) as pay_zl_order_amount
  307. from event_ok
  308. -- 支付成功
  309. where event = 'PayOrderSucceed' and actual_amount <= 200 and actual_amount>0
  310. -- 时间字段
  311. and date != '2020-08-15' -- 待补日期,当天日期
  312. group by date
  313. ) pos
  314. on vop.date = pos.date
  315. order by vop.date;
  316. # 向会员收入统计插入日期不为8月15的数据
  317. insert 产品收入_会员收入统计
  318. select
  319. rvf.date,
  320. pv_k.member_sx_cnt,-- 会员商详用户数
  321. rvf.receive_vip_user_cnt,-- 领取会员用户数
  322. if(pv_k.member_sx_cnt =0,0,rvf.receive_vip_user_cnt/pv_k.member_sx_cnt) as receive_pp, -- 领取转化率
  323. member_clk_cnt,-- 会员点击支付用户数
  324. if(member_sx_cnt=0,0,member_clk_cnt/member_sx_cnt) as clk_try2pay_pp, -- 点击转化率
  325. coalesce(pay_user_hy_cnt,0) as pay_user_hy_cnt, -- 购买会员用户数
  326. if(member_clk_cnt=0,0,coalesce(pay_user_hy_cnt/member_clk_cnt,0) )as try2scucess_pp, -- 支付转化率
  327. coalesce(pay_hy_order_amount,0) as pay_hy_order_amount, -- 购买总金额
  328. if(pay_user_hy_cnt=0,0,coalesce(pay_hy_order_amount/pay_user_hy_cnt,0)) as arppu_hy -- 人均消费
  329. from
  330. (
  331. select date ,count(distinct user_id) as receive_vip_user_cnt
  332. from event_ok
  333. -- 领取会员成功
  334. where event = 'ReceiveVipFreely'
  335. -- 时间字段
  336. and date != '2020-08-15' -- 待补时间,当天日期
  337. group by date
  338. ) rvf
  339. -- 进入会员详细页
  340. left join
  341. (
  342. select date,count(distinct user_id) as member_sx_cnt
  343. from event_ok
  344. where event = '$pageview' and $url like '%kaiwu.lagou.com/member%'
  345. -- 时间字段
  346. and date != '2020-08-15' -- 待补时间,当天日期
  347. group by date
  348. -- https://kaiwu.lagou.com/member/index
  349. ) pv_k
  350. on rvf.date = pv_k.date
  351. -- 会员点击支付按钮
  352. left join
  353. (
  354. select date, count(distinct user_id) as member_clk_cnt
  355. from event_ok
  356. where event = '$WebClick'
  357. -- and $url in ('https://kaiwu.lagou.com/member/index','https://kaiwu.lagou.com/member/index?appType=C&lagoufrom=ios&appVersion=7.0.1&randomize=704021827')
  358. and $url like '%kaiwu.lagou.com/member%'
  359. and $element_content = '¥688 开通365天会员'
  360. -- 时间字段
  361. and date != '2020-08-15' -- 待补时间,当天日期
  362. group by date
  363. ) wc_k
  364. on rvf.date = wc_k.date
  365. -- 付费成功
  366. left join
  367. (
  368. select date , count(distinct user_id) as pay_user_hy_cnt, sum(actual_amount) as pay_hy_order_amount
  369. from event_ok
  370. where event = 'PayOrderSucceed' and actual_amount>0 and order_type = '会员'
  371. -- 时间字段
  372. and date != '2020-08-15' -- 待补时间,当天日期
  373. group by date
  374. ) pay
  375. on rvf.date = pay.date
  376. order by rvf.date;
  377. #定义插入某天付费转化函数
  378. create FUNCTION insert_下载渠道付费转化率(riqi date) RETURNS int
  379. begin
  380. insert 下载渠道付费转化率
  381. select
  382. start_date,
  383. end_date,
  384. channel,num,pay_user,
  385. if(num=0,0,pay_user/num) as pay_rate,total_amount,amount_mean
  386. from
  387. (
  388. select if(DownloadChannel is null ,'iOS',DownloadChannel) as channel, count(distinct user_id) num
  389. from event_ok
  390. where event = 'AppInstall'
  391. -- 时间字段
  392. and date = DATE_SUB(riqi, Interval 14 DAY) -- 待补日期,当天日期
  393. group by 1
  394. ) appinstall
  395. #安装并付费的用户信息
  396. left join
  397. (
  398. select
  399. sub_AI.channel_2,
  400. count(distinct sub_AI.user_id) as pay_user,
  401. sum(pay.actual_amount_total) as total_amount,
  402. if(count(distinct sub_AI.user_id) =0,0, sum(pay.actual_amount_total)/count(distinct sub_AI.user_id)) as amount_mean,
  403. max(pay.Install_date) as end_date,
  404. min(pay.Install_date) as start_date
  405. from
  406. (
  407. select user_id, if(DownloadChannel is null ,'iOS',DownloadChannel) as channel_2,date as Install_date
  408. from event_ok
  409. where event = 'AppInstall'
  410. -- 时间字段
  411. and date = DATE_SUB(riqi, Interval 14 DAY) -- 待补日期,当天日期
  412. group by 1, 2,3
  413. ) sub_AI
  414. left join
  415. (
  416. select user_id, date as Install_date,
  417. case when actual_amount > 200 and order_type = '课程' then 1
  418. when actual_amount >0 and actual_amount <= 200 and order_type = '课程' then 2
  419. when order_type = '会员' then 3
  420. else -1 end as income_type,
  421. sum(actual_amount) as actual_amount_total
  422. from event_ok
  423. where event = 'PayOrderSucceed'
  424. -- 时间字段
  425. and date >= DATE_SUB(riqi, Interval 14 DAY) and date <= riqi -- 待补日期 两周转化周期
  426. group by 1,3,2
  427. ) pay on sub_AI.user_id = pay.user_id
  428. where pay.actual_amount_total>0
  429. group by 1
  430. order by 2 desc
  431. )temp
  432. on temp.channel_2 = appinstall.channel
  433. order by total_amount desc;
  434. return row_count();
  435. end;
  436. #调用函数,插入每天的付费转化率
  437. select insert_下载渠道付费转化率(date) from temp_riqi;
  438. # 向日报表中插入除8月15以外的数据
  439. insert 日报
  440. select
  441. -- 用户拉新表内
  442. 用户活跃_用户活跃留存.install_date as '日期',
  443. u_cnt_total as '激活人数',
  444. retention_u_cnt_total as '新用户次日留存人数',
  445. if(u_cnt_total =0,0,retention_u_cnt_total/u_cnt_total) as "新用户次日留存率",
  446. retention_u_cnt_total_7 as "新用户7日留存人数",
  447. if(u_cnt_total=0,0,retention_u_cnt_total_7/u_cnt_total) as "新用户7日留存率",
  448. retention_u_cnt_total_14 as "新用户14日留存人数",
  449. if(u_cnt_total=0,0,retention_u_cnt_total_14/u_cnt_total) as "新用户14日留存率",
  450. -- 用户活跃_用户活跃留存
  451. 用户活跃_用户活跃留存.dau as "DAU",
  452. first_dau as "首次活跃人数",
  453. if(用户活跃_用户活跃留存.dau =0,0,first_dau/用户活跃_用户活跃留存.dau) as "首次活跃用户占比",
  454. retention_dau_1 as "活跃用户次日留存人数",
  455. if(用户活跃_用户活跃留存.dau=0,0,retention_dau_1/用户活跃_用户活跃留存.dau) as "活跃用户次日留存率",
  456. retention_dau_7 as "活跃用户7日留存人数",
  457. if(用户活跃_用户活跃留存.dau=0,0,retention_dau_7/用户活跃_用户活跃留存.dau) as "活跃用户7日留存率",
  458. retention_dau_14 as "活跃用户14日留存人数",
  459. if(用户活跃_用户活跃留存.dau=0,0,retention_dau_14/用户活跃_用户活跃留存.dau) as "活跃用户14日留存率",
  460. -- 用户活跃_用户在线时长
  461. if(用户活跃_用户在线时长.dau=0,0,total_duration/用户活跃_用户在线时长.dau/60) as "平均单日使用时长(分)",
  462. -- 产品收入_总收入统计
  463. pay_user as "总付费人数",
  464. total_amount as "总付费金额",
  465. if(pay_user=0,0,total_amount/pay_user) as "客单价",
  466. pay_user_xly as "付费人数_训练营",
  467. total_amount_xly as "付费金额_训练营",
  468. if(pay_user_xly<>0,coalesce(total_amount_xly/pay_user_xly,0),0) as "客单价_训练营",
  469. pay_user_zl as "付费人数_专栏",
  470. total_amount_zl as "付费金额_专栏",
  471. if(pay_user_zl=0,0,coalesce(total_amount_zl/pay_user_zl,0)) as "客单价_专栏",
  472. pay_user_member as "付费人数_会员",
  473. total_amount_member as "付费金额_会员",
  474. if(pay_user_member <> 0,total_amount_member/pay_user_member,0) as "客单价_会员",
  475. -- 产品收入_训练营收入统计
  476. exp_xly_cnt as "曝光人数_训练营",
  477. exp_xly_pv as "曝光次数_训练营",
  478. if(exp_xly_cnt<>0, exp_xly_pv/exp_xly_cnt,0) as "平均曝光次数_训练营",
  479. clk_xly_cnt as "点击人数_训练营_app",
  480. clk_xly_pv as "点击次数_训练营_app",
  481. if(exp_xly_cnt<>0, clk_xly_cnt/exp_xly_cnt,0) as "点击率_训练营_uv",
  482. if(exp_xly_pv<>0, clk_xly_pv/exp_xly_pv,0) as "点击率_训练营_pv",
  483. -- 产品收入_训练营收入统计
  484. xly_sx_cnt as "浏览商详人数_训练营",
  485. xly_sx_cnt_app as "浏览商详人数_训练营_app",
  486. xly_appointment_cnt as "预约人数_训练营",
  487. if(xly_sx_cnt<>0,xly_appointment_cnt/xly_sx_cnt,0) as "浏览商详-预约转化率_训练营",
  488. if(xly_appointment_cnt<>0,pay_user_xly_cnt/xly_appointment_cnt,0) as "预约-付费转化率_训练营",
  489. if(xly_sx_cnt<>0,pay_xly_order_amount/xly_sx_cnt,0) as "单商详uv价值_训练营",
  490. -- 产品收入_专栏收入统计
  491. exp_zl_cnt as "曝光人数_专栏",
  492. exp_zl_pv as "曝光次数_专栏",
  493. if(exp_zl_cnt<>0,exp_zl_pv/exp_zl_cnt,0) as "人均曝光次数_专栏",
  494. clk_zl_cnt/7 as "点击人数_专栏" ,
  495. if(exp_zl_cnt<>0,clk_zl_cnt/exp_zl_cnt,0) as "点击率_专栏_uv",
  496. if(exp_zl_pv<>0,clk_zl_pv/exp_zl_pv,0) as "点击率_专栏_pv",
  497. zl_sx_uv as "浏览商详人数_专栏" ,
  498. zl_sx_uv_app as "浏览商详人数_专栏_app",
  499. zl_create_order_cnt as "下单人数_专栏",
  500. if(zl_sx_uv<>0,zl_create_order_cnt/zl_sx_uv,0) as "浏览商详-下单转化率_专栏",
  501. if(zl_create_order_cnt<>0,pay_user_zl_cnt/zl_create_order_cnt,0) as "下单-付费转化率_专栏",
  502. if(zl_sx_uv<>0,pay_zl_order_amount/zl_sx_uv,0) as "单商详uv价值_专栏",
  503. -- 产品收入_会员收入统计
  504. member_sx_cnt as "浏览商详人数_会员",
  505. receive_vip_user_cnt as "领取会员人数",
  506. if(member_sx_cnt <> 0, receive_vip_user_cnt / member_sx_cnt,0) as "浏览商详-领取会员转化率_会员",
  507. member_clk_cnt as "点击支付人数_会员"
  508. from 用户活跃_用户活跃留存
  509. left join (select DISTINCT install_date,
  510. min(u_cnt_total) as u_cnt_total, -- 日安装用户总数
  511. min(retention_u_cnt_total) as retention_u_cnt_total, -- 次日留存用户总数
  512. min(retention_u_cnt_total_7) as retention_u_cnt_total_7 , -- 日留存用户总书
  513. min(retention_u_cnt_total_14) as retention_u_cnt_total_14 -- 日留存用户总书
  514. from 用户拉新 group by install_date) as 新用户
  515. on 用户活跃_用户活跃留存.Install_date = 新用户.install_date
  516. left join 用户活跃_用户在线时长 on 用户活跃_用户在线时长.Install_date = 新用户.install_date
  517. left join 产品收入_总收入统计 on 产品收入_总收入统计.Install_date = 新用户.install_date
  518. left join 产品收入_训练营收入统计 on 产品收入_训练营收入统计.date = 新用户.install_date
  519. left join 产品收入_专栏收入统计 on 产品收入_专栏收入统计.date = 新用户.install_date
  520. left join 产品收入_会员收入统计 on 产品收入_会员收入统计.date = 新用户.install_date
  521. where 用户活跃_用户活跃留存.install_date != '2020-08-15';
  522. #重写周报所有数据
  523. delete from 周报;
  524. insert 周报
  525. select
  526. -- 用户拉新表内
  527. DATE_SUB(用户活跃_用户活跃留存.install_date,INTERVAL WEEKDAY(用户活跃_用户活跃留存.install_date) DAY) as '当周周一',
  528. sum(u_cnt_total)/7 as '激活人数',
  529. sum(retention_u_cnt_total)/7 as '新用户次日留存人数',
  530. if(sum(u_cnt_total)=0,0,sum(retention_u_cnt_total)/sum(u_cnt_total)) as "新用户次日留存率",
  531. sum(retention_u_cnt_total_7)/7 as "新用户7日留存人数",
  532. if(sum(u_cnt_total)=0,0,sum(retention_u_cnt_total_7)/sum(u_cnt_total)) as "新用户7日留存率",
  533. sum(retention_u_cnt_total_14)/7 as "新用户14日留存人数",
  534. if(sum(u_cnt_total)=0,0,sum(retention_u_cnt_total_14)/sum(u_cnt_total)) as "新用户14日留存率",
  535. -- 用户活跃_用户活跃留存
  536. sum(用户活跃_用户活跃留存.dau)/7 as "DAU",
  537. sum(first_dau)/7 as "首次活跃人数",
  538. if(sum(用户活跃_用户活跃留存.dau)=0,0,sum(first_dau)/sum(用户活跃_用户活跃留存.dau)) as "首次活跃用户占比",
  539. sum(retention_dau_1)/7 as "活跃用户次日留存人数",
  540. if(sum(用户活跃_用户活跃留存.dau) =0,0,sum(retention_dau_1)/sum(用户活跃_用户活跃留存.dau)) as "活跃用户次日留存率",
  541. sum(retention_dau_7)/7 as "活跃用户7日留存人数",
  542. if(sum(用户活跃_用户活跃留存.dau)=0,0,sum(retention_dau_7)/sum(用户活跃_用户活跃留存.dau)) as "活跃用户7日留存率",
  543. sum(retention_dau_14)/7 as "活跃用户14日留存人数",
  544. if(sum(用户活跃_用户活跃留存.dau)=0,0,sum(retention_dau_14)/sum(用户活跃_用户活跃留存.dau)) as "活跃用户14日留存率",
  545. -- 用户活跃_用户在线时长
  546. if(sum(用户活跃_用户在线时长.dau)=0,0,sum(total_duration)/sum(用户活跃_用户在线时长.dau)/60) as "平均单日使用时长(分)",
  547. -- 产品收入_总收入统计
  548. sum(pay_user)/7 as "总付费人数",
  549. sum(total_amount)/7 as "总付费金额",
  550. if(sum(pay_user)=0,0,sum(total_amount)/sum(pay_user)) as "客单价",
  551. sum(pay_user_xly)/7 as "付费人数_训练营",
  552. sum(total_amount_xly) /7 as "付费金额_训练营",
  553. if(sum(pay_user_xly)=0,0,coalesce(sum(total_amount_xly)/sum(pay_user_xly),0)) as "客单价_训练营",
  554. sum(pay_user_zl)/7 as "付费人数_专栏",
  555. sum(total_amount_zl)/7 as "付费金额_专栏",
  556. if(sum(pay_user_zl)=0,0,coalesce(sum(total_amount_zl)/sum(pay_user_zl),0)) as "客单价_专栏",
  557. sum(pay_user_member)/7 as "付费人数_会员",
  558. sum(total_amount_member)/7 as "付费金额_会员",
  559. if(sum(pay_user_member) <> 0,sum(total_amount_member)/sum(pay_user_member),0) as "客单价_会员",
  560. -- 产品收入_训练营收入统计
  561. sum(exp_xly_cnt)/7 as "曝光人数_训练营",
  562. sum(exp_xly_pv)/7 as "曝光次数_训练营",
  563. if(sum(exp_xly_cnt)<>0, sum(exp_xly_pv)/sum(exp_xly_cnt),0) as "平均曝光次数_训练营",
  564. sum(clk_xly_cnt)/7 as "点击人数_训练营_app",
  565. sum(clk_xly_pv)/7 as "点击次数_训练营_app",
  566. if(sum(exp_xly_cnt)<>0, sum(clk_xly_cnt)/sum(exp_xly_cnt),0) as "点击率_训练营_uv",
  567. if(sum(exp_xly_pv)<>0, sum(clk_xly_pv)/sum(exp_xly_pv),0) as "点击率_训练营_pv",
  568. -- 产品收入_训练营收入统计
  569. sum(xly_sx_cnt)/7 as "浏览商详人数_训练营",
  570. sum(xly_sx_cnt_app)/7 as "浏览商详人数_训练营_app",
  571. sum(xly_appointment_cnt)/7 as "预约人数_训练营",
  572. if(sum(xly_sx_cnt)<>0,sum(xly_appointment_cnt)/sum(xly_sx_cnt),0) as "浏览商详-预约转化率_训练营",
  573. if(sum(xly_appointment_cnt)<>0,sum(pay_user_xly_cnt)/sum(xly_appointment_cnt),0) as "预约-付费转化率_训练营",
  574. if(sum(xly_sx_cnt)<>0,sum(pay_xly_order_amount)/sum(xly_sx_cnt),0) as "单商详uv价值_训练营",
  575. -- 产品收入_专栏收入统计
  576. sum(exp_zl_cnt)/7 as "曝光人数_专栏",
  577. sum(exp_zl_pv)/7 as "曝光次数_专栏",
  578. if(sum(exp_zl_cnt)<>0,sum(exp_zl_pv)/sum(exp_zl_cnt),0) as "人均曝光次数_专栏",
  579. sum(clk_zl_cnt)/7 as "点击人数_专栏" ,
  580. if(sum(exp_zl_cnt)<>0,sum(clk_zl_cnt)/sum(exp_zl_cnt),0) as "点击率_专栏_uv",
  581. if(sum(exp_zl_pv)<>0,sum(clk_zl_pv)/sum(exp_zl_pv),0) as "点击率_专栏_pv",
  582. sum(zl_sx_uv)/7 as "浏览商详人数_专栏" ,
  583. sum(zl_sx_uv_app)/7 as "浏览商详人数_专栏_app",
  584. sum(zl_create_order_cnt)/7 as "下单人数_专栏",
  585. if(sum(zl_sx_uv)<>0,sum(zl_create_order_cnt)/sum(zl_sx_uv),0) as "浏览商详-下单转化率_专栏",
  586. if(sum(zl_create_order_cnt)<>0,sum(pay_user_zl_cnt)/sum(zl_create_order_cnt),0) as "下单-付费转化率_专栏",
  587. if(sum(zl_sx_uv)<>0,sum(pay_zl_order_amount)/sum(zl_sx_uv),0) as "单商详uv价值_专栏",
  588. -- 产品收入_会员收入统计
  589. sum(member_sx_cnt)/7 as "浏览商详人数_会员",
  590. sum(receive_vip_user_cnt)/7 as "领取会员人数",
  591. if(sum(member_sx_cnt) <> 0,sum(receive_vip_user_cnt)/sum(member_sx_cnt),0) as "浏览商详-领取会员转化率_会员",
  592. sum(member_clk_cnt)/7 as "点击支付人数_会员"
  593. from 用户活跃_用户活跃留存
  594. left join
  595. (select DISTINCT install_date,
  596. u_cnt_total, -- 日安装用户总数
  597. retention_u_cnt_total, -- 次日留存用户总数
  598. retention_u_cnt_total_7, -- 日留存用户总书
  599. retention_u_cnt_total_14 -- 日留存用户总书
  600. from 用户拉新) as 新用户 on 用户活跃_用户活跃留存.Install_date = 新用户.install_date
  601. left join 用户活跃_用户在线时长 on 用户活跃_用户在线时长.Install_date = 新用户.install_date
  602. left join 产品收入_总收入统计 on 产品收入_总收入统计.Install_date = 新用户.install_date
  603. left join 产品收入_训练营收入统计 on 产品收入_训练营收入统计.date = 新用户.install_date
  604. left join 产品收入_专栏收入统计 on 产品收入_专栏收入统计.date = 新用户.install_date
  605. left join 产品收入_会员收入统计 on 产品收入_会员收入统计.date = 新用户.install_date
  606. group by 1;

执行时间较长。

活动吸引的新用户数以及新用户留存

#分享拉新用户及次日,7日,14日留存
select A.date as 日期, count(distinct a.user_id) as 拉新数,count(distinct
a.user_id)*20 as 活动支出,
COUNT(distinct if(DATEDIFF(T_Start.Date,A.Date)=1,A.user_id,Null)) as 次日留存,
COUNT(distinct if(DATEDIFF(T_Start.Date,A.Date)=7,A.user_id,Null)) as 7日留存,
COUNT(distinct if(DATEDIFF(T_Start.Date,A.Date)=14,A.user_id,Null)) as 14日留存
from
    (
        select
            date,
            user_id
        from
            event_ok
        where
            `$is_first_day` = 1
            and EVENT = '$AppStart'
        group by
            date,
            user_id
    ) as A
    inner join (
        select
            date,
            user_id
        from
            event_ok
        where
            EVENT = 'ReceiveVipFreely'
            and share_user_id is not null
    ) as B -- 结论 : 两次活动留存对比 , 第二次活动留存情况较差 。 由于7日 、 14 日留存的时间点比较特殊 , 扩展留存曲线观察拉新用户留存效果 。 
        on A.date = B.date
    and A.user_id = B.user_id
    left join (
        select
            date,
            user_id
        from
            event_ok
        where
            EVENT = '$AppStart'
        group by
            date,
            user_id
    ) as T_Start on A.user_id = T_Start.user_id
    and (
        DATE_SUB(T_Start.Date, Interval 1 DAY) = A.date
        or DATE_SUB(T_Start.Date, Interval 7 DAY) = A.date
        or DATE_SUB(T_Start.Date, Interval 14 DAY) = A.date
    )
where
    A.Date in('2020-08-17', '2020-09-23')
group by
    A.date

执行结果

image.png

活动的K因子

select
    a.date,
    count(distinct a.user_id),
    count(DISTINCT share_user_id)
from
    (
        select
            distinct user_id,
            date
        from
            event_ok
        where
            `$is_first_day` = 1
            and EVENT = '$AppStart'
            and date in('2020-08-17', '2020-09-23')
    ) as A
    INNER JOIN (
        select
            distinct user_id,
            date,
            share_user_id
        from
            event_ok
        where
            EVENT = 'ReceiveVipFreely'
            and date in('2020-08-17', '2020-09-23')
            and share_user_id is not null
    ) as B on a.user_id = b.user_id
    and a.date = b.date
group by
    A.date

执行结果

image.png

分析活动的转化情况

#19天内的转化
select
    A.date,
    count(distinct T_Start.user_id)
from
    (
        select
            date,
            user_id
        from
            event_ok
        where
            `$is_first_day` = 1
            and EVENT = '$AppStart'
        group by
            date,
            user_id
    ) as A
    inner join (
        select
            date,
            user_id
        from
            event_ok
        where
            EVENT = 'ReceiveVipFreely'
            and share_user_id is not null
    ) as B on A.date = B.date
    and A.user_id = B.user_id
    left join (
        select
            date,
            user_id
        from
            event_ok
        where
            EVENT = 'PayOrderSucceed'
            and actual_amount > 200
        group by
            date,
            user_id
    ) as T_Start on A.user_id = T_Start.user_id
    and DATE_SUB(T_Start.Date, Interval 20 DAY) < A.date
    and T_Start.Date >= A.date
where
    A.Date in('2020-08-17', '2020-09-23')
group by
    A.date

执行结果

image.png

异常数据分析

通过图表分析可以得到异常的数据波动,首先要确定异常点的数据是计算异常还是数据的异常,正常情况下需要一层层做数据验证,从底层即数据库到应用层即用户。

然后分析这个波动的点是不是异常点,是不是已知的问题导致的。

其次确认这个点是不是人为的还是自发的,人为指的是公司活动引导导致,自发指的是用户行为导致的。如果是公司异常一般能从埋点发现,反之是自发。

最后详细梳理异常数据产生的原因。

最后异常解决及回顾

数据异常通过统计学方法时间序列分析进行预测并计算。