yanmai

一.  项目背景

1.  用户行为

用户行为是用户在商品上产生的行为过程,通过相应的行为数据可以展现出来。

2. 用户行为分析

1) 目的

探索用户行为规律,结合实际商品实际情况进行优化,实现业务增长

根据用户价值划分,优化用户管理体系

2)用途

通过对用户行为数据的研究

  • 可以还原用户行为模式,了解用户行为习惯
  • 发现商品在这个过程中存在的问题,优化商品信息
  • 提高用户行为的转化率,实现精准化运营
  • 区分用户价值,精细化用户管理

二.  数据来源

天池实验室-数据集-User Behavior Data from Taobao for Recommendation

链接:https://tianchi.aliyun.com/dataset/dataDetail?dataId=649&userId=1

数据集介绍:

  • 本数据集包含了2017年11月25日至2017年12月3日之间
  • 有行为的约一百万随机用户的所有行为(包括点击、购买、加购、喜欢)
  • 数据集的每一行表示一条用户行为,由用户ID、商品ID、商品类目ID、行为类型和时间戳组成,并以逗号分隔

三. 分析思路

1. 了解用户购物习惯

指标:PV(访问量),UV(独立访客),跳失率,活跃时间段

2. 找出商品销售规律

指标:成交量,复购率,购买次数

3. 行为转化率漏斗分析

收藏转化率,购物车转化率,购买转化率

4. 用户聚类分析

利用RFM模型

四. 使用语言及环境

  • navicat
  • python3
  • jupyter notebook
  • Excel

五. 分析过程及结论

1.  数据集筛选

  • 由于原数据的时间是时间戳格式,需要转换成日期格式
  • 其次原数据的数据量较大
  • 基于以上两点认为用mysql对时间戳进行处理最佳
# 将查询的结果插入新表
CREATE TABLE user1 AS 
SELECT *, FROM_UNIXTIME(f5,\'%Y-%m-%d %H:%i:%s\') datetimes, FROM_UNIXTIME(f5,\'%Y-%m-%d\') dates, FROM_UNIXTIME(f5,\'%H\') hours
FROM userbehavior;
  • 根据年月日的日期列,筛选出在2017年11月25日至2017年12月3日之间的数据集

CREATE TABLE user2 AS SELECT * FROM user
WHERE dates BETWEEN \'2017-11-25\' AND \'2017-12-03\';

2.  分析过程

2.1  需要的库

import pandas as pd

2.2  数据审查

  • 读取数据并添加列索引
data = pd.read_csv(\'user2.csv\', names=[\'User ID\', \'Item ID\', \'Category ID\', \'Behavior type\', \'Timestamp\', \'Datetimes\', \'Dates\', \'Hours\'])
  • 查看数据读取结果
print(\'{:*^60}\'.format(\'Data Overview\'))
print(data.head(2))

 output:

***********************Data Overview************************
   User ID  Item ID  Category ID Behavior type   Timestamp  \
0        1  2268318      2520377            pv  1511544070   
1        1  2333346      2520771            pv  1511561733   

             Datetimes       Dates  Hours  
0  2017-11-25 01:21:10  2017-11-25      1  
1  2017-11-25 06:15:33  2017-11-25      6  
  • 查看数据属性的类型
print(\'{:*^60}\'.format(\'Data Dtypes\'))
print(pd.DataFrame(data.dtypes).T)

 output:

************************Data Dtypes*************************
  User ID   Item ID   Category ID  Behavior type  Timestamp  Datetimes   Dates    Hours
0   int64   int64       int64        object         int64     object     object   int64
  • 查看数据的行数和列数
print(\'{:*^60}\'.format(\'Data Shape\'))
print(data.shape)

 output:

*************************Data Shape************************* 
(3833395, 8)
  • 查看缺失值
print(\'{:*^60}\'.format(\'NA Sum\'))
print(data.isnull().any().sum())

 output:

***************************NA Sum***************************
0

2.3  数据预处理

时间格式在Mysql中已经处理过了,并新增了三列新的属性,分别为具体时间,年月日以及小时;

2.4  用户购物情况分析

  • 浏览量PV
type_count = data.groupby(data[\'Behavior type\'])[\'User ID\'].count()
PV = type_count[\'pv\']
PV

 output:

3431914
  • 独立访客UV
user_id = data[\'User ID\'].unique()
UV = len(user_id)
UV

 output:

37376
  • 访问深度(人均页面浏览量)
PV/UV

 output:

91.82132919520548
  • 跳失率
data_filter = data[data[\'Behavior type\'].isin([\'buy\', \'cart\', \'fav\'])]
filter_id = data_filter[\'User ID\'].unique()
only_pv = data[~data[\'User ID\'].isin(list(filter_id))]
pv_id = only_pv[\'User ID\'].unique()
len(pv_id)/UV

 output:

0.05875428082191781
  • 每天访问量情况
from matplotlib import pyplot as plt
%matplotlib inline
plt.style.use(\'ggplot\')
data_pv = data[data[\'Behavior type\'] == \'pv\']
views = data_pv.groupby(\'Dates\')[\'User ID\'].nunique()
views.plot(kind=\'bar\', color=\'y\')
plt.grid(axis=\'x\')

output:

Dates
2017-11-25    25944
2017-11-26    26377
2017-11-27    26098
2017-11-28    26138
2017-11-29    26578
2017-11-30    26981
2017-12-01    27235
2017-12-02    35557
2017-12-03    35455
Name: User ID, dtype: int64

                 

  • 每天访客情况
visitors = data.groupby(\'Dates\')[\'User ID\'].nunique() 
visitors
from matplotlib import pyplot as plt
%matplotlib inline
plt.style.use(\'ggplot\')
visitors.plot(kind=\'bar\', color=\'blue\')
plt.grid(axis=\'x\')

output:

Dates
2017-11-25    26710
2017-11-26    27107
2017-11-27    26893
2017-11-28    26976
2017-11-29    27394
2017-11-30    27844
2017-12-01    28065
2017-12-02    36701
2017-12-03    36614
Name: User ID, dtype: int64

  • 每个时段访问量和访客数
select a.hours,a.访问量,b.访客数 from
(select hours,count(behavior_type)as 访问量 from user2
where behavior_type=\'pv\'
group by hours) a
inner join 
(select hours,count(distinct user_id) as 访客数 from user2
group by hours) b
on a.hours=b.hours
order by hours;

         

 

  • 不同时段成交量
select hours,count(behavior_type)as 成交量 from user2
where behavior_type=\'buy\'
group by hours
order by hours;

 

          

2.5  商品购买情况分析

  • 成交量

用户行为是“buy”的总量

select dates,count(behavior_type) as 成交量 from user2
where behavior_type=\'buy\'
group by dates;

 

 

  •  人均购买次数
select count(behavior_type)as 订单量,count(distinct user_id)as 用户数,count(behavior_type)/count(distinct user_id)as 人均购买次数
from user2
where behavior_type=\'buy\';

 

 

 

  •  复购率

复购率 = 购买次数超过2的用户数/总购买用户数

# 购买两次及以上用户数
select count(*) from 
(select count(user_id) as 重复购买用户数 from user2
where behavior_type=\'buy\'
group by user_id)a
where a.重复购买用户数>1;

# 总购买用户数
select count(distinct user_id) as 用户数 from user2
where behavior_type=\'buy\';

 

复购率 = 16712/25400 = 66%

  • 重复被购买次数前10的商品
select item_id,count(behavior_type)被购买次数 from user2
where behavior_type=\'buy\'
group by item_id
order by count(behavior_type) desc
limit 10;

 

 

  •  重复购买次数前10的客户
select user_id,count(user_id)as 购买次数 from user2
where behavior_type=\'buy\'
group by user_id
order by count(user_id) desc
limit 10;

 

 2.6  转化漏斗分析

  • 用户行为情况
#用户行为情况:
select behavior_type,count(behavior_type) from User_Behavior
group by behavior_type
order by count(behavior_type) desc;

 

 

 

可见真正转化为购买的只有2%,用户在浏览商品详情页后出现了大量的流失。

那么,从浏览到购买,每一个环节的转化率是多少呢?因为加入购物车和收藏商品并没有行为的先后性,也就是说,购物路线可以有两条:

第一条线路:浏览—加入购物车—购买

第二条线路:浏览—添加收藏—购买

  • 购物车转化率=加入购物车后购买的用户数/加入购物车的用户数
select count(distinct a.user_id)as 加入购物车用户数,count(distinct b.user_id)as 加入后购买用户数 from
(select distinct user_id,item_id,category_id, timestampe from user2 where behavior_type=\'cart\')a
left join
(select distinct user_id,item_id,category_id,timestampe from user2 where behavior_type=\'buy\')b
on a.user_id=b.user_id and a.item_id=b.item_id and a.category_id=b.category_id and a.timestampe<b.timestampe;

由查询结果可知,

加入购物车的用户数为:28122

加入购物车后购买的用户数:8503

所以,购物车转化率为:8503/28122= 30.24%,约为30%

也就是说,加入购物车的用户中,有30%会进行购买。

  • 浏览的用户量
select count(distinct user_id) from User_Behavior where behavior_type=\'pv\';

 

结果为:37223

从结果可以看出,从用户点击浏览到购买商品,用户浏览到加入购物车的转化率是很高的,达到了75.5%,说明大部分用户在浏览后有购买意向,加入了购物车;但是,在加入购物车到购买的环节里,只有30%左右的用户进行了真正的购买,而70%的用户是没有进一步购买的。为什么用户加入购物车后却并没有购买呢?

推测原因可能是:

  1. 加入购物车是为了与不同店铺的同种产品进行比价;
  2. 为了凑单,进行满减;
  3. 先放着,过几天再购买;
  4. 等活动优惠
  • 收藏转化率=添加收藏后购买的用户数/添加收藏的用户数
select count(distinct a.user_id)as 收藏用户数,count(distinct b.user_id)as 收藏后购买用户数 from 
(select distinct user_id,item_id,category_id,timestampe from user2 where behavior_type=\'fav\')a
left join
(select distinct user_id,item_id,category_id,timestampe from user2 where behavior_type=\'buy\')b
on a.user_id=b.user_id and a.item_id=b.item_id and a.category_id=b.category_id and a.timestampe<b.timestampe;

由查询结果可知,

加入收藏的用户数为:14943

加入收藏后购买的用户数:3233

所以,收藏转化率为:3233/14943=21.64%,约等于22%

与线路一的购买流程来看,用户在浏览后,相对于收藏行为,会更倾向于添加到购物车。而且购物车转化率为30%,收藏转化率为21%,购物车转化率比收藏转化率高,也就是说,用户更偏向于购物车购买。

推测原因:加入购物车后可以直接下单购买,而加入收藏后并没有可以下单的页面,如果需要购买必须重新点击商品进入详情页才能下单,多了一个步骤,所以,在这个步骤里可能用户就流失了部分

六.  总结

  1. 12月2日与12月3日,相对于其他日期,流量增长明显,推测和搞活动有关;
  2. 大部分用户在18时到21时会比较活跃,其中21到22时,是一天当中最活跃的时段,成交量也是这一时段最高。建议可以在用户活跃的时段进行推广以使运营效果最大化。
  3. 这段时间,人均购买次数为3,复购率达到66%,说明店铺产品对用户吸引力比较大。
  4. 被重复购买得比较频繁的商品是item_id为3122135等商品,对于复购率高的商品,建议可以建立自己的忠实粉丝群,实行更精准的人群管理。
  5. 用户ID为107932 等的用户是重复购买次数最多的用户。建议对于这些忠实用户,建议要更全面地了解,开发用户信息库,建立详实的用户资料数据库,追踪记录顾客的交易情况。或者线上组建VIP客户微信群等,针对这些用户的购买偏好推送更精准的销售方案。
  6. 用户行为转化率只有2%,有98%的用户行为是没有转化为成交的,用户在浏览商品详情页后出现了大量的流失。建议通过活动、优惠券、产品详情页的改进等提高转化。
  7. 从浏览到加入购物车的转化有75.5%,大部分用户在浏览后有购买意向;加入购物车到真正购买的,只有30%,有70%的用户加入购物车后却并没有进一步购买。
  8. 建议在用户加入购物车后能有促进用户下单的利益“诱导”,如赠送优惠券或采用倒计时购物车增加客户购买紧近感。
  9. 从收藏到购买的转化率为21%。相对于购物车30%的转化率,收藏转化率稍低。
  10. 同样建议在用户添加收藏后能提示优惠或促销等时限信息,促使用户尽早下单。

参考链接:https://zhuanlan.zhihu.com/p/76267568

分类:

技术点:

相关文章: