Hadoop环境中使用Hive工具实现电商网站用户运营分析

news/2024/5/9 3:38:56/文章来源:https://blog.csdn.net/weixin_55759540/article/details/117709433

文章目录

  • 一、分析目标
  • 二、数据说明
  • 三、实现步骤
    • 1.建立用户指标体系
    • 2.建立分阶段用户标签
      • 2.1 按用户行为统计每日的不同阶段用户规模
      • 2.2 按周为单位分析最近两周的不同阶段用户的变化
      • 2.3 对比分析新用户群体与激活用户群体的人群画像、行为数据特点
    • 3、用户复购分析
      • 3.1 计算2月1日至4月30日用户的复购情况
      • 3.2 对比复购用户和非复购用户的用户画像、行为特点
      • 3.3 结合最后一周的分阶段用户标签,分析近期复购用户的用户激活、用户流失的情况
    • 4、报告

一、分析目标

1.搭建日常运营指标体系;
2.分析现有用户构成,统计每日用户构成情况;
3.分析用户复购情况,为后续复购运营做指导。

二、数据说明

User_info 用户信息表:
在这里插入图片描述
user_action 用户行为表:
在这里插入图片描述

三、实现步骤

首先需要搭建运营指标体系,让运营人员能够看到用户规模以及规模的变动状态;然后我们需要按照用户阶段(新用户、激活用户、睡眠用户、流失用户)将用户区分出来,统计每天不同阶段的用户数量,让运营能够了解不同阶段用户规模,设计更加贴切的用户运营方案。

建表:

create table user_info
(user_id string,
age_between string,
sex int,
user_level int,
reg_time date
) 
row format delimited fields terminated by '\t'
tblproperties("skip.header.line.count"="1"); load data local inpath '/home/hadoop/datas/HomeWork/user_info_sample.txt' into table
user_info;ALTER TABLE user_info SET SERDEPROPERTIES ('serialization.encoding'='GBK');create table User_action
(user_id string,
sku_id string,
action_time Timestamp,
model_id int,
type int,
cate int,
brand int
) 
row format delimited fields terminated by '\t'
tblproperties("skip.header.line.count"="1"); --转载时跳过第一行
--装载数据
load data local inpath '/home/hadoop/datas/HomeWork/user_action_sample.txt' into
table user_action;

1.建立用户指标体系

我们需要根据用户活跃指标来逐步建立用户指标体系:

  • 每日活跃用户数:DAU,即每日活跃用户的排重统计量;
selectdate(action_time) action_time,count(distinct user_id) DAU
fromuser_action
group bydate(action_time);
  • 每日新注册用户数:DNU,即每日新注册用户的排重统计量;
selectreg_time,count(distinct user_id)
from user_info
group by reg_time;
  • 每日消费转化率:即每日所有用户的有下单行为的用户数与每日活跃用户数的百分比;
selectdate(action_time) action_time,concat(round(count(distinct if(type=4,user_id,Null))/count(distinct user_id)*100,2),"%") as per_con_rate
from user_action
group by date(action_time)
order by date(action_time);
  • 每日新用户消费转化率:即每日新注册用户中,有下单行为的用户数与每日新注册用户数的百分比;
selectreg_time,concat(round(count(distinct if(type=4,user_info.user_id,Null))/count(distinct user_info.user_id)*100,2),"%") as new_per_con_rate
from user_info
left join user_action on user_info.reg_time=date(user_action.action_time)
and user_info.user_id=user_action.user_id
group by reg_time
order by reg_time;

分析近期各个指标的变动特点:

select action_time,concat(round((DAU - DAU_1)/DAU_1 *100,2),"%") as DAU_DOD,concat(round((DNU - DNU_1)/DNU_1 *100,2),"%") as DNU_DOD,concat(round((per_con_rate - per_con_rate_1) / per_con_rate_1 *100,2),"%") as per_con_rate_DOD,concat(round((new_per_con_rate - new_per_con_rate_1) / new_per_con_rate_1 *100,2),"%") as new_per_con_rate_DOD,concat(round((DAU - DAU_7)/DAU_7 *100,2),"%") as DAU_WOW,concat(round((DNU - DNU_7)/DNU_7 *100,2),"%") as DNU_WOW,concat(round((per_con_rate - per_con_rate_7) / per_con_rate_7 *100,2),"%") as per_con_rate_WOW,concat(round((new_per_con_rate - new_per_con_rate_7) / new_per_con_rate_7 *100,2),"%") as new_per_con_rate_WOW
from(select *,lag(DAU,1) over(order by action_time) as DAU_1,lag(DNU,1) over(order by action_time) as DNU_1,lag(per_con_rate,1) over(order by action_time) as per_con_rate_1,lag(new_per_con_rate,1) over(order by action_time) as new_per_con_rate_1,lag(DAU,7) over(order by action_time) as DAU_7,lag(DNU,7) over(order by action_time) as DNU_7,lag(per_con_rate,7) over(order by action_time) as per_con_rate_7,lag(new_per_con_rate,7) over(order by action_time) as new_per_con_rate_7from(select date(action_time) action_time,count(distinct user_id) DAU,concat(round(count(distinct if(type=4,user_id,Null))/count(distinct user_id)*100,2),"%") as per_con_ratefrom user_actiongroup by date(action_time) ) as table_aleft join(select reg_time,count(distinct user_info.user_id) as DNU,concat(round(count(distinct if(type=4,user_info.user_id,Null))/count(distinct user_info.user_id)*100,2),"%") as new_per_con_ratefrom  user_infoleft join user_action on user_info.user_id=user_action.user_idand reg_time=date(action_time)group by reg_time) as table_b on table_a.action_time=table_b.reg_time) as table_c
order by action_time;

2.建立分阶段用户标签

  • 将注册当天的用户作为新用户
riqi=reg_time
  • 将注册未满一周的用户作为未激活用户(为了避免新用户成为跳出用户)
(max_time-reg_time<7 or max_time is Null) and riqi-reg_time<14
  • 注册后的第8天,用户进入激活期,激活期为注册后的第8到第14天,在激活期回访的用户,则成为激活用户。(为了让未激活用户成为激活用户)
max_time-reg_time>7 and riqi-max_time<7
  • 若用户成为激活用户后,有一周没有活跃;或从注册后在激活期(第8到第14天)未激活且第14天之后也未活跃的用户作为睡眠用户。(主要做唤醒)
(max_time-reg_time>7 and riqi-max-time>7 and riqi-max_time<=21)
or(riqi-reg_time>14 and riqi-reg_time<=28 and (max_time-reg_time<7 or max_time is Null))
  • 将成为睡眠用户后,有两周没有活跃的用户作为流失用户。(虽然同为唤醒范围,但是流失用户的唤醒难度要大于睡眠用户,在预算较少的唤醒活动中不予考虑。)
(max_time-reg_time>7 and riqi-max_time>21) or
(riqi-reg_time>28 and (max_time-reg_time<7 or max_time is Null))

之所以我们需要统计不同阶段的用户,是因为我们仅从DAU、DNU或MAU数据都很难去观察我们用户池的用户构成如何,用户是沉淀下来了逐渐变多?还是在逐渐减少?这些是需要我们通过将不同阶段用户细拆之后才能统计出来的。

2.1 按用户行为统计每日的不同阶段用户规模

当新增用户、未激活用户、激活用户增加,且睡眠用户、流失用户减少,那我们的用户规模就在呈上升趋势;反之,则呈下降趋势。分析近期我们用户规模的变动趋势,判断我们的用户池的健康程度。

-- 准备统计日期数据(每日都要统计,故将用户行为表中的时间单独拉出作为统计时间)
create table riqi as
select date(action_time) riqi from user_action group by date(action_time);-- 准备最后一次用户行为时间(由于统计日统计的是上一次的行为时间,故约束统计日期上一次行为时间作为最后一次行为时间。riqi表是单独拉出的连续时间,并非用户最后一次行为时间,riqi表时间与用户行为时间无关) 
create table base_info as
select riqi,user_id,reg_time,(select max(action_time) max_time from user_action where date(action_time)<riqi.riqi and user_id=user_info.user_id) as max_time
from riqi,user_info;select riqi,user_type,count(*)
from(select *,case when riqi=reg_time then "new_user"when ( day(max_time-reg_time)<7 or max_time is Null) and day(riqi-reg_time)<14 then "inaction_user"when day(max_time-reg_time)>7 and day(riqi-max_time)<7 then "action_user"when (day(max_time-reg_time)>7 and day(riqi-max_time)>7 and day(riqi-max_time)<=21) or (day(riqi-reg_time)>14 and day(riqi-reg_time)<=28 and (day(max_time-reg_time)<7 or max_time is Null)) then "sleep_user"when (day(max_time-reg_time)>7 and day(riqi-max_time)>21) or (day(riqi-reg_time)>28 and (day(max_time-reg_time)<7 or max_time is Null)) then "lose_user"end as user_typefrom base_info
) as a
group by riqi,user_type;

2.2 按周为单位分析最近两周的不同阶段用户的变化

用户量变化、人均浏览数变化、人均点击数变化、人均加购物车数变化、人均下单数变化、购买转化率变化。

select if(date(action_time)>"2016-04-08","week_1","week_2") as week,count(distinct user_id) DAU_week,round(count(if(type=1,user_id,Null))/count(distinct user_id),2) avg_user1,round(count(if(type=6,user_id,Null))/count(distinct user_id),2) avg_user6,round(count(if(type=2,user_id,Null))/count(distinct user_id),2) avg_user2,round(count(if(type=4,user_id,Null))/count(distinct user_id),2) avg_user4,concat(round(count(distinct if(type=4,user_id,Null))/count(distinct user_id)*100,2),"%") buy_rate
from(
select * from user_action where date(action_time)>"2016-04-01"
) as a
group by date(action_time)>"2016-04-08";

2.3 对比分析新用户群体与激活用户群体的人群画像、行为数据特点

简述近期产品引入的新用户群体是否健康。

-- 新用户群体
select age_between,sex,count(distinct a.user_id) count_user,round(count(if(type=1,a.user_id,Null))/count(distinct a.user_id),2) avg_user1,round(count(if(type=6,a.user_id,Null))/count(distinct a.user_id),2) avg_user6,round(count(if(type=2,a.user_id,Null))/count(distinct a.user_id),2) avg_user2,round(count(if(type=4,a.user_id,Null))/count(distinct a.user_id),2) avg_user4,concat(round(count(distinct if(type=4,a.user_id,Null))/count(distinct a.user_id)*100,2),"%") buy_rate 
from
(select * from user_info where reg_time>"2016-04-08" and reg_time<="2016-04-15") as a
left join 
(select * from user_action where date(action_time)>"2016-04-08") as b
on a.user_id=b.user_id
group by age_between,sex
grouping sets(age_between,sex);-- 激活用户群体
select age_between,sex,count(distinct a.user_id) count_user,round(count(if(type=1,a.user_id,Null))/count(distinct a.user_id),2) avg_user1,round(count(if(type=6,a.user_id,Null))/count(distinct a.user_id),2) avg_user6,round(count(if(type=2,a.user_id,Null))/count(distinct a.user_id),2) avg_user2,round(count(if(type=4,a.user_id,Null))/count(distinct a.user_id),2) avg_user4,concat(round(count(distinct if(type=4,a.user_id,Null))/count(distinct a.user_id)*100,2),"%") buy_rate 
from
(select * from user_info where reg_time<="2016-04-08") as a
inner join 
(select * from user_action where date(action_time)>"2016-04-08") as b
on a.user_id=b.user_id
group by age_between,sex
grouping sets(age_between,sex);

3、用户复购分析

对于用户运营来说,由于获客成本居高不下,提升用户复购是将用户价值最大化的关键。

那到底什么时候该关注复购,凯文·希尔斯特罗姆在《精益数据分析》一书中给了参考:

  • 90天内重复购买率达到1%~15%;说明你处于用户获取模式;把更多的精力和资源投入到新用户获取和转化;

  • 90天内重复购买率达到15~30%;说明你处于混合模式;平衡用在新用户转化和老用户留存、复购上的精力和资源;

  • 90天内重复购买率达到30%以上;说明你处于忠诚度模式;把更多的精力和资源投入到用户复购上;

3.1 计算2月1日至4月30日用户的复购情况

  • 用户复购率 = 复购用户数 / 活跃用户数;
  • 复购用户数 :一段时间内购买次数达两次及以上的用户数

经过统计,用户的复购率为8.87%,说明产品处于用户获取模式。

select 
count(if(buy_count>=2,user_id,Null)) re_buy,
count(distinct user_id) AU,
concat(round(count(if(buy_count>=2,user_id,Null))/count(distinct user_id)*100,2),"%") as re_buy_rate
from 
(select user_id,count(if(type=4,user_id,Null)) buy_count
from user_action
where date(action_time)>="2016-02-01"
group by user_id) as a;

3.2 对比复购用户和非复购用户的用户画像、行为特点

结合用户信息表和用户购买行为表,可以看出复购用户的特点:复购用户26-35岁的男性居多。

-- 复购用户
select age_between,sex,
count(if(buy_count>=2,a.user_id,Null)) re_buy,
count(distinct a.user_id) AU,
concat(round(count(if(buy_count>=2,a.user_id,Null))/count(distinct a.user_id)*100,2),"%") as re_buy_rate
from 
(select user_id,count(if(type=4,user_id,Null)) buy_count from user_action
group by user_id) as a
left join
(select user_id,age_between,sex from user_info) as b
on a.user_id=b.user_id
group by age_between,sex
grouping sets(age_between,sex);-- 非复购用户
select age_between,sex,
count(if(buy_count<2,a.user_id,Null)) not_re_buy,
count(distinct a.user_id) AU,
concat(round(count(if(buy_count<2,a.user_id,Null))/count(distinct a.user_id)*100,2),"%") as not_re_buy_rate
from 
(select user_id,count(if(type=4,user_id,Null)) buy_count from user_action
group by user_id) as a
left join
(select user_id,age_between,sex from user_info) as b
on a.user_id=b.user_id
group by age_between,sex
grouping sets(age_between,sex);

3.3 结合最后一周的分阶段用户标签,分析近期复购用户的用户激活、用户流失的情况

select user_type,count(distinct user_id) user_num
from(
select distinct a.user_id as user_id,case when reg_time="2016-04-15" then "new_user"when (day(max_time-reg_time)<=7 or max_time is Null)and reg_time>"2016-04-01" then "inaction_user"when day(max_time-reg_time)>7 and max_time>"2016-04-08" then "action_user"when (day(max_time-reg_time)>7 and max_time<"2016-04-08" and max_time>="2016-03-25") or (reg_time<"2016-04-01" and reg_time>="2016-03-18" and (day(max_time-reg_time)<7 or max_time is Null)) then "sleep_user"when (day(max_time-reg_time)>7 and max_time<"2016-03-25") or (reg_time<"2016-03-18" and (day(max_time-reg_time)<7 or max_time is Null)) then "lose_user"end as user_type
from
(select a1.user_id user_id,a1.action_time action_time,max(a1.action_time)over(partition by a1.user_id) max_time
from(select user_id,date(action_time) action_time,count(user_id)over(partition by user_id) buy_countfrom user_action where type=4) as a1 where buy_count>=2)as a
left join
(select user_id,reg_time from user_info) as b
on a.user_id=b.user_id
) as c
group by user_type; 

4、报告

https://gitee.com/Ariel999/data-analysis-case/blob/master/Hive%E5%AD%A6%E4%B9%A0/%E7%94%A8%E6%88%B7%E8%BF%90%E8%90%A5%E5%89%8D%E6%9C%9F%E5%88%86%E6%9E%90%E6%8A%A5%E5%91%8A-%E5%BC%A0%E8%8D%A3%E8%8D%A3.pptx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_883312.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

手把手教你!0基础小白也可以使用谷歌服务器搭建自己的博客网站

准备工作 visa卡&#xff08;用于谷歌的认证&#xff09;fan&#xff08;翻&#xff09;qiang&#xff08;墙&#xff09;工具&#xff08;用于登陆谷歌&#xff09; 一 申请及注册谷歌云 1.登录Google Cloud官网并进行账户注册&#xff1a;https://cloud.google.com/ ,我们…

网站看板娘--偷就完事了(大雾)

最近项目做完了&#xff0c;想到博客园有些博主的博客有看板娘&#xff0c;就偷过来了 下面将一步步还原我偷的过程&#xff08;笑&#xff09; 首先准备一个html&#xff0c;放在tomcat的webapps的文件夹下&#xff0c;下载好的live2d文件夹&#xff08;提取码&#xff1a;d…

基于java的在线答疑网站系统——计算机毕业设计

网络答疑系统已经成为远程教育网站不可缺少的组成部分&#xff0c;它对提高远程教育的质量起着至关重要的作用。但目前的网络答疑系统功能比较简单、答疑效率低、智能性不高。随着人工智能和自然语言处理等相关技术的发展&#xff0c;未来的网络答疑系统将会在智能性、开放性、…

基于java的婚恋交友动态网站——计算机毕业设计

“网络红娘”的出现不仅对传统交友方式和恋爱观形成强烈冲击&#xff0c;更形成了一门具有良好发展前景的新兴产业。与欧美国家相比&#xff0c;我国婚恋网站起步较晚&#xff0c;目前仍处于跑马圈地的群雄纷争时代&#xff0c;一家独大的行业巨头尚未出现。虽然部分专业婚恋网…

Java+MySQL 基于Springboot+vue的鲜花销售商城网站——毕业设计

项目编号:JavaMySQL spring272-基于Springbootvue的鲜花销售商城网站#毕业设计 开发语言&#xff1a;Java 开发工具:IDEA /Eclipse 数据库:MYSQL5.7 应用服务:Tomcat7/Tomcat8 使用框架:springbootvue 鲜花一直以来都是人们生活中的一个增色剂。尤其是在一些特殊的节日鲜…

Java+MySQL 基于Springboot+vue的零食销售商城网站——毕业设计

项目编号:JavaMySQL spring271-基于Springbootvue的零食销售商城网站#毕业设计 开发语言&#xff1a;Java 开发工具:IDEA /Eclipse 数据库:MYSQL5.7 应用服务:Tomcat7/Tomcat8 使用框架:springbootvue ​随着人们生活条件的改善&#xff0c;人们对生活的追求也越来越高。…

计算机毕业设计之java+ssm电影视频预约推荐网站

本基于SSM框架的电影预约推荐系统主要包含了等系统用户管理、影视分类管理、电影预约信息管理、预约信息审核管理多个功能模块,系统采用了jsp的mvc框架,SSM(springMvcspringMybatis)框架进行开发. 管理员的登录模块&#xff1a;管理员登录系统对本系统其他管理模块进行管理。 …

计算机毕业设计之java+SSM动物园门票预订网站系统

现代化动物园管理系统日趋复杂&#xff0c;传统的以手工方式为主的管理操作模式&#xff0c;局限性日趋突显&#xff1a;宣传手段单一&#xff0c;管理效率低,系统采用了jsp的mvc框架,SSM(springMvcspringMybatis)框架进行开发,本系统使用mysql&#xff0c;独立运行,不依附于其…

基于jsp+java的音乐网站

介绍&#xff1a; jspservletmysqleclipse技术 效果截图&#xff1a; 数据库表&#xff1a; CREATE TABLE admin ( id int(11) NOT NULL AUTO_INCREMENT, adminName varchar(20) COLLATE utf8_bin DEFAULT NULL, adminPwd varchar(20) COLLATE utf8_bin DEFAULT NULL,…

基于java的出租车预约网站

出租车预约网站能够有效的解决大家上班下班打不到车&#xff0c;加快吃饭逛街的效率&#xff0c;天阴下雨无障碍出行&#xff0c;自己有车不舍得开等问题,使得用户查询车辆信息更加方面快捷&#xff0c;同时便于管理员对车辆和用户的管理&#xff0c;从而给出租车管理公司的预约…

基于java网上订餐网站系统

通过网上西餐厅网上订餐管理系统这个平台&#xff0c;消费者足不出户就可以了解大量的西餐厅菜单信息&#xff0c;给消费者带来了极大的方便。网上西餐厅管理系统平台的主要功能包括菜单类别管理、菜单信息管理等&#xff0c;根据客户种类又可以划分成管理员客户和会员客户两种…

基于java的企业信息网站发系统

设计并实现基于 web 的企业信息发布系统&#xff0c;在现有的 Web技术的基础上&#xff0c;采用windows serverTomcatMySQLJSP的体系&#xff0c;利用 JSP&#xff08;Java Server Page&#xff09;技术开发动态网页&#xff0c;实现客户端对服务器的动态访问。包括对服务器中的…

基于java的校园网络教学网站系统

建立校园精品课程网站&#xff0c;尽可能提高优质教学的利用率&#xff0c;对实现人才培养&#xff0c;促进社会经济发展都能起到十分重要的作用。也可以引导用户主动年该学习&#xff0c;提高学习效率&#xff0c;更为教学双方提供一个进行写作学习和交流的平台。 设计开发了创…

java基于springboot的在线选课网站—计算机毕业设计

运行环境&#xff1a; 开发工具:IDEA /Eclipse 数据库:MYSQL5.7 应用服务:Tomcat7/Tomcat8 使用框架:springbootjsp 项目介绍 在学生在线选课系统的实现下&#xff0c;学生在线选课人员能够充分发挥信息化处理的优势&#xff0c;提高日常管理的处理速率。用户一方可以更好的享…

java基于ssm+vue的旅游景点推荐网站-计算机毕业设计

随着人民生活水平的提高,旅游业已经越来越大众化,而旅游业的核心是信息,不论是对旅游管理部门、对旅游企业,或是对旅游者而言,有效的获取旅游信息,都显得特别重要.旅游景点推荐网站将使旅游相关信息管理工作规范化、信息化、程序化,提供旅游景点、购票、预订、旅游新闻等服务.该…

SEO网站外链全自动在线发布工具PHP源码

这是一款SEO网站外链在线全自动发布工具的网站源码&#xff0c;内置上千条外链发布接口&#xff0c;SEO外链发布工具的原理就是通过网站源码内置的外链接口&#xff0c;输入域名之后&#xff0c;通过访问这些外链接口&#xff0c;即可在互联网上面产生大量的网站外链&#xff0…

八个移动产品设计必备网站

八个移动产品设计必备网站 2012-06-21 09:53 [小 大] 来源: cocoachina 评论: 我来评论 分享至: 百度权重查询 站长交易 友情链接交换 网站监控 服务器监控 SEO监控 移动产品设计人员一定需要大量的使用其他各类应用&#xff0c;并且需要在产品设计时大量参考其他的移动应用…

php查询下载-手机,IP,QQ,WHOIS,PR ,ALEXA,手机号,网站收录,身份证,生日

1 php查询下载-手机,IP,QQ,WHOIS,PR ,ALEXA,手机号,网站收录,身份证,生日看见很多朋友需要这个查询系统&#xff08;PHP&#xff09;&#xff0c;暂时先放本版5小时 http://www.myand.com/viewthread. ... ghlight&page3 [发布]php查询系统下载-手机,IP,QQ,域名WHOIS,PR ,…

网站想更换域名,请教有经验的朋友,如何实现流量和搜索引擎上的平滑过度?

网站想更换域名&#xff0c;请教有经验的朋友&#xff0c;如何实现流量和搜索引擎上的平滑过度&#xff1f;网站想更换域名&#xff0c;请教有经验的朋友&#xff0c;如何实现流量和搜索引擎上的平滑过度&#xff1f;流失尽量少的人气&#xff0c;有什么好办法没有&#xff1f;…

实验操作:shell脚本实现监控网站是否正常,异常发邮件------------------含泪写shell,写完刷皮皮虾

监控网站是否正常&#xff0c;异常发邮件 要求&#xff1a;需求分析&#xff1a;1、发送邮件脚本2、配置监控 要求&#xff1a; 写一个shell脚本&#xff0c;通过curl -I 返回状态码来判定所访问的网站是否正常&#xff0c;比如当代码状态200&#xff0c;才算正常写一个发邮件…