什么是瀏覽量(PV)
瀏覽量和訪問(wèn)次數(shù)是呼應(yīng)的。用戶訪問(wèn)網(wǎng)站時(shí)每打開(kāi)一個(gè)頁(yè)面,就記為1個(gè)PV。同一個(gè)頁(yè)面被訪問(wèn)多次,瀏覽量也會(huì)累積。一個(gè)網(wǎng)站的瀏覽量越高,說(shuō)明這個(gè)網(wǎng)站的知名度越高,內(nèi)容越受用戶喜歡。一味地重視PV也是沒(méi)有太大意義的(PV跟點(diǎn)擊量差不多吧)。
PV是一個(gè)重要的指標(biāo),反映了網(wǎng)站內(nèi)容是否對(duì)用戶有足夠的吸引力。對(duì)于競(jìng)價(jià)而言,只能是側(cè)面反映,因?yàn)槲覀冊(cè)O(shè)置了訪問(wèn)URL。很多用戶需求也非常明確,來(lái)到網(wǎng)站之后,往往只會(huì)尋找自己需求的產(chǎn)品,所以一味地重視PV也是沒(méi)有太大意義的。應(yīng)該把重點(diǎn)內(nèi)容展示給目標(biāo)客戶就可以了,就沒(méi)必要一味地追求PV值,追求那些轉(zhuǎn)化率、跳出率、UV、轉(zhuǎn)化次數(shù)等那才是重點(diǎn)。
準(zhǔn)備數(shù)據(jù)
數(shù)據(jù)文件:order.txt
字段意義:step, name, pv
1,廣告,10000
2,菜單,3000
3,商品詳情,2600
4,購(gòu)物車(chē),300
5,下單,200
6,支付,190
7,支付成功,189
創(chuàng)建表
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;
統(tǒng)計(jì)轉(zhuǎn)化率
相對(duì)于最初步驟的轉(zhuǎn)化率
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;
結(jié)果:
+-------+-------+--------+---------------------+
| step | name | pv | pct |
+-------+-------+--------+---------------------+
| 1 | 廣告 | 10000 | 100.0 |
| 2 | 菜單 | 3000 | 30.0 |
| 3 | 商品詳情 | 2600 | 26.0 |
| 4 | 購(gòu)物車(chē) | 300 | 3.0 |
| 5 | 下單 | 200 | 2.0 |
| 6 | 支付 | 190 | 1.9 |
| 7 | 支付成功 | 189 | 1.8900000000000001 |
+-------+-------+--------+---------------------+
每一步驟相對(duì)于上一步驟的轉(zhuǎn)化率
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;
結(jié)果數(shù)據(jù):
+-------+-------+--------+---------------------+
| step | name | pv | pct |
+-------+-------+--------+---------------------+
| 1 | 廣告 | 10000 | 100.0 |
| 2 | 菜單 | 3000 | 30.0 |
| 3 | 商品詳情 | 2600 | 86.66666666666667 |
| 4 | 購(gòu)物車(chē) | 300 | 11.538461538461538 |
| 5 | 下單 | 200 | 66.66666666666666 |
| 6 | 支付 | 190 | 95.0 |
| 7 | 支付成功 | 189 | 99.47368421052632 |
+-------+-------+--------+---------------------+