(SQL)电商-用户行为分析

目录

一、明确分析目的

二、数据收集

三、数据处理

四、数据分析与展现

五、总结与建议

一、提出问题

1.1分析目的

本文在已有的电商用户行为的基础上,挖掘数据价值,研究时间段用户的转化、下单以及商品销售情况。从而对业务提出建议,提升电商关键指标.....

具体研究问题如下:

1、用户在什么时间段最活跃,容易下单?

2、关键行为指标转化情况如何?

3、如何提高指标间转化率,从而提高订单量?

4、那些商品转化情况最好?那些最差,如何优化?

5、那些商品类目最受欢迎,订单量最高?

1.2分析框架


分析框架

二、数据理解

2.1数据来源-阿里云天池

链接:电商用户行为数据

2.2数据介绍

该数据为用户在2017年11月25日至12月3日之间具有点击,购买,向购物车中添加商品和偏好商品的所有行为。

数据集由用户ID(user_id),商品ID(item_id),商品类目ID(item_category),行为类型(behavior_type)和时间戳(create_time)组成。分析样本量为3835331条数据。(原数据集约1亿)。

2.3数据导入

此处参考:Linux环境下,MySQL数据导入,不做详细赘述。

三、数据处理

表名:use_behavior2

样本数据:3835331条

样本数据

3.1删除重复数据

distinct 删除重复值,保留3835329条数据放入use_behavior2_2表中。

create table use_behavior2_2 asselect distinct * from use_behavior2 

处理重复项后数据

3.2缺失值处理

在创建表格表格时,5个字段均定义为not null;数据导入保证没有缺失值。

create table use_behavior2(user_id int(5) not null,#用户iditem_id int(20) not null,#商品名称item_category int(20) not null,#商品类目behavior_type varchar(45) not null,#行为类型create_time int(20) not null);#时间戳

3、将时间戳转化为日期时间形式,同时增加日期、时间、周三列

#将时间戳转化为日期时间

alter table use_behavior2_2 add column datetime2 varchar(30) null;

update use_behavior2_2 set datetime2 =from_unixtime(create_time,'%Y-%m-%d %H:%i:%s');

#增加日期列

alter table use_behavior2_2 add column dates date null;

update use_behavior2_2 setdates = date_format(datetime2,'%Y-%m-%d')

#增加时间列

alter table use_behavior2_2 add column times time null;

update use_behavior2_2 set times = date_format(datetime2,'%H:%i:%s')

#增加周列

alter table use_behavior2_2 add column weekdays char(10) null;

update use_behavior2_2 set weekdays = date_format(dates,'%W')

执行结果如下:

转化为日期时间形式

3.4数据异常值处理

#确定日期是否在规定范围内:2017年11月25日至2017年12月3日。

select max(datetime2),min(datetime2) ,max(create_time ),min(create_time ) from use_behavior2_2 ub

执行结果:

异常值处理

将不符合规定的数据删除,一共删除1945条数据:

delete from use_behavior2_2 where datetime2 < '2017-11-25 00:00:00' or datetime2 > '2017-12-04 00:00:00'


再次验证日期时间的准确性,下面结果满足要求:

异常值处理

3.5判断行为数据

#判断行为是否为点击浏览(pv),收藏(fav),加入购物车(cart),购买(buy)

select behavior_type from use_behavior2_2 ub group by behavior_type

执行结果:

判断行为数据

完成以上数据处理,最终获得3833384条数据进行数据分析。

四、构建模型

1、整体情况

1.1关键指标概览

select behavior_type,count(*) as 次数,count(distinct user_id) as 人数 from use_behavior2_2 ub group by behavior_type order by behavior_type desc

关键指标概览

1.2平台活跃趋势

#平台整体活动趋势

select dates as 日期,weekdays,count(*) as 次数,count(distinct user_id) as 人数from use_behavior2_2 ub group by dates;

整体变化趋势

在这个周期内,活跃度最高是在12月2号,12月3号这两天,明显有提升。

从平常日活情况来看,日常活跃人数稳定在2.6万-2.8万之间。而12月2号、12月3号为周六,周日,在周末效应之下,日活高达3.6万,商品点击次数也有了明显的上升。

从该时间段数据情况可推测周末活跃度高于工作日。因用户的闲暇时间的增加,活跃与购买情况会明显高于工作日。因此可多选取一段时间对规律进行验证,若属实,建议平台与商家在营销活动与运营安排中,注意结合客流量对日常、周末以及法定节假日等节点进行合理安排。

1.3每日购买变动情况

#每日购买变动情况

select dates as 日期,behavior_type as 行为类型,count(*) as 订单数,count(distinct item_id)as 商品数量 from use_behavior2_2 ub where behavior_type = 'buy' or behavior_type ='cart'group by dates,behavior_type

 从该购买情况来看,12月2号,3号周末两天的购买情况同时增长,加入购物车和购买也同步发生变化。

2、平台活跃分析

2.1 分时段活跃情况

#分时段活跃情况

select date_format(times,'%H:00:00') as 时段,count(*) as 次数,count(distinct user_id) as 用户数from use_behavior2_2group by 时段

订单分时段活跃情况

10点到23为活跃高峰期:10点开始进入,一直到19点活跃度基本平稳没有明显的差异。20-21点开始迎来高峰,持续到22-23点出现下降。

2.2 12月2号,12月3号分时段活跃情况

#12月2.3平台分时段活跃情况

select date_format(times,'%H:00:00') as 时段,count(*) 次数,count(distinct user_id) as 用户数from use_behavior2_2 ub where dates ='2017-12-02' or dates = '2017-12-03'group by 时段


周末分时段活跃变化

周末与日常活跃趋势基本一致,10点进入活跃高峰期期,20-21点迎来高峰期。

建议平台与商户夜间活跃的特性,做好客户服务时间,营销消息推送等安排,以达到更好的促交易目的。

3、订单分析

3.1分时段下单情况

#3.1分时段下单情况

select date_format(times,'%H:00:00') as 时段,count(distinct user_id) as 用户数,count(*) as 订单from use_behavior2_2 ub where behavior_type = 'buy'group by 时段


下单时段分析

下单的整体趋势与活跃基本一致,但高峰期增长较小。晚间最高峰20点-22点与白天10点到17点变动趋势基本一致,无太大变化。导致这一现象的可能原因是,晚间高峰期用户有更多的时间和轻松的范围,会无意识浏览商品,贡献活跃。

3.2销量top10 产品    

#3.2销量top10 产品

select item_id ,count(*) as 订单量from use_behavior2_2 ub where behavior_type = 'buy'group by item_id order by 订单量 desc limit 10


top10商品

以上10款商品是平台该事件段内销量最高的10款商品,建议结合商品表对商品特性与商品信息分析其受欢迎的原因,从而考虑如何引导商户调整商品结构。

3.3客户量top10的商品

#3.3客户量top10的商品

select item_id,count(distinct user_id)as 用户数from use_behavior2_2 ub where behavior_type = 'buy'group by item_id order by 用户数 desc limit 10

购买客户量最高的top10商品

以上10款商品是平台该段时间内购买客户数最高的10款商品。

3.4销量最高的10大品类

#3.4销量最高的10大品类

select item_category as 商品类目,count(*) as 订单量,count(distinct item_id) as 商品数量from use_behavior2_2 ub2 where behavior_type = 'buy'group by item_category order by 商品数量 desc limit 10

top10品类

3.5最受客户欢迎的10大品类

#3.5最受客户欢迎的10大品类

select item_category,count(distinct user_id) as 用户数,count(distinct item_id)as 商品数量from use_behavior2_2 ub where behavior_type = 'buy'group by item_category order by 用户数 desc limit 10

最受客户欢迎的10大品类

3.6订单量最少的10个商品

#3.6订单最少的10个商品

select item_id,count(*) as 订单from use_behavior2_2 ub where behavior_type = 'buy'group by item_id order by 订单 asc limit 10

订单量最少的10个商品

3.7订单量最少的10个品类

#3.7订单量最少的10个品类

select item_category,count(*) as 订单from use_behavior2_2 ub where behavior_type = 'buy'group by item_category order by 订单 asc limit 10

订单量最少的10个品类

结合更多商品信息,分析这10个品类订单量低的原因,是类目下商品太少?还是其下商品是季节性产品?亦或是商品类目拆分过细?

4、转化漏斗分析

#用户漏斗转化分析

create view u3 asselect behavior_type,count(user_id) as 用户数from use_behavior2_2 ub group by behavior_type order by behavior_type desc                     

select behavior_type,(用户数/10000) as 用户数(单位万) from u3 

点击—购买转化漏斗

从商品转化情况来看,从点击到加入购物车或者收藏,近9.46%转化率,该转化率过低,建议商家针对商品的详情、标题等进行优化,提高用户转化率;

从商品购买转化情况来看,如果订单被加入购物车或收藏,将有23.62%的可能性成交;

从点击至下单,转化率为2.24%。

说明:考虑到fav(收藏)与cart(加购)无直接转化关系,随本案例做合并处理。

5、下单用户分析

5.1用户购买频次分析

#5.1用户购买频次分析

create view u1 as select user_id,count(*) as 订单量from use_behavior2_2 ub where behavior_type = 'buy'group by user_id

select 订单量,count(*) as 用户数 from u1group by 订单量

从用户购买频次来看,在这9天时间里,有34.2%用户只成交1单,23.22%用户成交2单。最高成交量为10单以上占比3.18%。

建议结合下单金额等指标,制定高净值用户评价体系,从而为平台营销提供数据支持。

5.2用户排行榜

#5.2用户排行榜

select user_id,count(*) as 订单量,count(distinct item_id) as 商品数量from use_behavior2_2 ub where behavior_type = 'buy'group by user_id order by 订单量 desc limit 10

用户排行榜

商品的成交是对平台最有价值的指标,也是用户体现价值的重要方式。建议对平台高成交量,高成交额用户予以关注与精益化运营。

5.2复购商品分析

#5.2复购商品分析

select user_id,item_id,count(*) as 订单量from use_behavior2_2 ub where behavior_type = 'buy'group by user_id ,item_id having count(*)>1order by 订单量 desc;

一部分是复购商品的信息

根据执行结果,从所有成交订单来看,有3187款商品被复购。

五、总结与建议。

1、周末为高活跃、高成交时间,建议运营活动的指定,运营策略的安排对该因素予以关注;

2、20到21点为每日高峰期,建议平台与用户做好人员安排和营销信息安排。

3、综合商品信息进一步挖掘表现突出的几款商品及商品类目受欢迎的原因,以及对低成交的几款商品进行流失原因分析。

4、由点击至加入购物车亦或收藏的转化太低,建议商家从商品详情页入手,做好商品详情页的优化,提高用户转化;

5、构建用户价值评定体系,为平台运营策略提供数据支持,实现精细化运营不同价值用户。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容