什么是浏览量(PV)
浏览量和访问次数是呼应的。用户访问网站时每打开一个页面,就记为1个PV。同一个页面被访问多次,浏览量也会累积。一个网站的浏览量越高,说明这个网站的知名度越高,内容越受用户喜欢。一味地重视PV也是没有太大意义的(PV跟点击量差不多吧)。
PV是一个重要的指标,反映了网站内容是否对用户有足够的吸引力。对于竞价而言,只能是侧面反映,因为我们设置了访问URL。很多用户需求也非常明确,来到网站之后,往往只会寻找自己需求的产品,所以一味地重视PV也是没有太大意义的。应该把重点内容展示给目标客户就可以了,就没必要一味地追求PV值,追求那些转化率、跳出率、UV、转化次数等那才是重点。
准备数据
数据文件:order.txt
字段意义:step, name, pv
1,广告,10000
2,菜单,3000
3,商品详情,2600
4,购物车,300
5,下单,200
6,支付,190
7,支付成功,189
创建表
create database if not exists hive_order;
use hive_order;
drop table if exists t_order;
create table t_order(step int, name string, pv int) row format delimited fields
terminated by ",";
load data local inpath "/home/bigdata/order.txt" into table t_order;
select * from t_order limit 10;
统计转化率
相对于最初步骤的转化率
set hive.mapred.mode = nonstrict;
select aa.step as step, aa.name as name, aa.apv as pv, aa.apv/aa.bpv * 100 as
pct from
(select a.step as step, a.name as name, a.pv as apv, b.bpv as bpv
from t_order a, (select max(pv) as bpv from t_order) b) aa;
结果:
+-------+-------+--------+---------------------+
| step | name | pv | pct |
+-------+-------+--------+---------------------+
| 1 | 广告 | 10000 | 100.0 |
| 2 | 菜单 | 3000 | 30.0 |
| 3 | 商品详情 | 2600 | 26.0 |
| 4 | 购物车 | 300 | 3.0 |
| 5 | 下单 | 200 | 2.0 |
| 6 | 支付 | 190 | 1.9 |
| 7 | 支付成功 | 189 | 1.8900000000000001 |
+-------+-------+--------+---------------------+
每一步骤相对于上一步骤的转化率
create table order_trans as
select a.step as step, a.name as name, a.pv as apv, b.pv as bpv
from t_order a join t_order b
on a.step = b.step + 1
where a.step != 1
union
select a.step as step, a.name as name, a.pv as apv, a.pv as bpv
from t_order a where a.step == 1;
select a.step as step, a.name as name, a.apv as pv, a.apv/a.bpv * 100 as pct
from order_trans a;
结果数据:
+-------+-------+--------+---------------------+
| step | name | pv | pct |
+-------+-------+--------+---------------------+
| 1 | 广告 | 10000 | 100.0 |
| 2 | 菜单 | 3000 | 30.0 |
| 3 | 商品详情 | 2600 | 86.66666666666667 |
| 4 | 购物车 | 300 | 11.538461538461538 |
| 5 | 下单 | 200 | 66.66666666666666 |
| 6 | 支付 | 190 | 95.0 |
| 7 | 支付成功 | 189 | 99.47368421052632 |
+-------+-------+--------+---------------------+