Z05 - 029、模块开发:统计分析 - 流量分析 - 基础指标多维统计分析

本文介绍了网站流量分析中的基础指标统计,包括PageView、Unique Visitor、访问次数(VV)和IP,并详细讲解了多维统计分析,如按时间、referer、终端和栏目维度的统计方法。通过解析User Agent获取终端信息,以及根据URL解析栏目进行统计。
摘要由CSDN通过智能技术生成
初学耗时:0.5h

注:CSDN手机端暂不支持章节内链跳转,但外链可用,更好体验还请上电脑端。

一、模块开发:统计分析 - 流量分析 - 基础指标多维统计分析
  1.1  基础指标统计。
  1.2  多维统计分析。



记忆词:

  基础指标统计、多维统计分析

Z05 - 999、网站流量日志分析


ギ 舒适区ゾ || ♂ 累觉无爱 ♀





一、模块开发:统计分析 - 流量分析 - 基础指标多维统计分析

  1.1 ~ 基础指标统计。
  • 对于指标业务含义的解读是关键。
    1.1.1 .  PageView 浏览次数(pv)
# 排除静态资源
select count(*) from ods_weblog_detail where datestr ="20181101" and valid = "true"; 
    1.1.2 .  Unique Visitor 独立访客(UV)
select count(distinct remote_addr) as uvs from ods_weblog_detail where datestr ="20181101";
    1.1.3 .  访问次数(VV)
select count(distinct session) as vvs from ods_click_stream_visit where datestr ="20181101";
    1.1.4 .  IP
select count(distinct remote_addr) as ips from ods_weblog_detail where datestr ="20181101";
create table dw_webflow_basic_info(month string,day string,
pv bigint,uv bigint ,ip bigint, vv bigint) partitioned by(datestr string);
insert into table dw_webflow_basic_info partition(datestr="20181101")

select '201811','01',a.*,b.* from
(select count(*) as pv,count(distinct remote_addr) as uv,count(distinct remote_addr) as ips 
from ods_weblog_detail
where datestr ='20181101') a join 
(select count(distinct session) as vvs from ods_click_stream_visit where datestr ="20181101") b;
  1.2 ~ 多维统计分析。
    1.2.1 .  按时间维度。
  1. 直接在 ods_weblog_detail 单表上进行查询。
# 计算该处理批次(一天)中的各小时 pvs
drop table dw_pvs_everyhour_oneday;
create table dw_pvs_everyhour_oneday(month string,day string,hour string,pvs bigint) partitioned by(datestr 
string);
insert into table dw_pvs_everyhour_oneday partition(datestr='20130918')
select a.month as month,a.day as day,a.hour as hour,count(*) as pvs from ods_weblog_detail a
where a.datestr='20130918' group by a.month,a.day,a.hour;

# 计算每天的 pvs
drop table dw_pvs_everyday;
create table dw_pvs_everyday(pvs bigint,month string,day string);
insert into table dw_pvs_everyday
select count(*) as pvs,a.month as month,a.day as day from ods_weblog_detail a
group by a.month,a.day;
  1. 与时间维表关联查询。
# 维度:日
drop table dw_pvs_everyday;
create table dw_pvs_everyday(pvs bigint,month string,day string);
insert into table dw_pvs_everyday
select count(*) as pvs,a.month as month,a.day as day from (select distinct month, day from t_dim_time) a
join ods_weblog_detail b 
on a.month=b.month and a.day=b.day
group by a.month,a.day;

# 维度:月
drop table dw_pvs_everymonth;
create table dw_pvs_everymonth (pvs bigint,month string);
insert into table dw_pvs_everymonth
select count(*) as pvs,a.month from (select distinct month from t_dim_time) a
join ods_weblog_detail b on a.month=b.month group by a.month;

# 另外,也可以直接利用之前的计算结果。比如从之前算好的小时结果中统计每一天的
Insert into table dw_pvs_everyday
Select sum(pvs) as pvs,month,day from dw_pvs_everyhour_oneday group by month,day having day='18';
    1.2.2 .  按 referer 维度。
# 统计每小时各来访 url 产生的 pv 量
drop table dw_pvs_referer_everyhour;
create table dw_pvs_referer_everyhour(referer_url string,referer_host string,month string,day string,hour 
string,pv_referer_cnt bigint) partitioned by(datestr string);
insert into table dw_pvs_referer_everyhour partition(datestr='20130918')
select http_referer,ref_host,month,day,hour,count(1) as pv_referer_cnt
from ods_weblog_detail 
group by http_referer,ref_host,month,day,hour 
having ref_host is not null
order by hour asc,day asc,month asc,pv_referer_cnt desc;
# 统计每小时各来访 host 的产生的 pv 数并排序
drop table dw_pvs_refererhost_everyhour;
create table dw_pvs_refererhost_everyhour(ref_host string,month string,day string,hour string,ref_host_cnts 
bigint) partitioned by(datestr string);
insert into table dw_pvs_refererhost_everyhour partition(datestr='20130918')
select ref_host,month,day,hour,count(1) as ref_host_cnts
from ods_weblog_detail 
group by ref_host,month,day,hour 
having ref_host is not null
order by hour asc,day asc,month asc,ref_host_cnts desc;

alt

    1.2.3 .  按终端维度。
  • 数据中能够反映出用户终端信息的字段是 http_user_agent。
  • User Agent 也简称 UA。它是一个特殊字符串头,是一种向访问网站提供所使用的浏览器类型及版本、操作系统及版本、浏览器内核、等信息的标识。
  • 例如:
User-Agent,Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) 
Chrome/58.0.3029.276 Safari/537.36
  • 上述 UA 信息就可以提取出以下的信息:

chrome 58.0、浏览器 chrome、浏览器版本 58.0、系统平台 windows、浏览器内核 webkit

感兴趣的可以查看参考资料:《如何自定义 UDF 解析 UA》。

    1.2.4 .  按栏目维度。
  • 网站栏目可以理解为网站中内容相关的主题集中。体现在域名上来看就是不同的栏目会有不同的二级目录。
  • 比如某网站网址为 www.xxxx.cn,旗下栏目可以通过如下方式访问:

栏目维度:…/job
栏目维度:…/news
栏目维度:…/sports
栏目维度:…/technology

  • 那么根据用户请求 url 就可以解析出访问栏目,然后按照栏目进行统计分析。


二十四桥明月夜,玉人何处教吹箫?

- - - - - - - - - - - - - - - - - - - - - - - - - - - -



^ 至此,模块开发:统计分析 - 流量分析 - 基础指标多维统计分析完成。


- - - - - - - - - - - - - - - - - - - - - - - - - - - -


※ 世间诱惑何其多,坚定始终不动摇。

版本控制软件ClearCase涵盖的范围包括 _____、建立管理、工作空间管理和过程控制。


版本控制
alt



二十四桥明月夜,玉人何处教吹箫?

- - - - - - - - - - - - - - - - - - - - - - - - - - - -


注:CSDN手机端暂不支持章节内链跳转,但外链可用,更好体验还请上电脑端。

我知道我的不足,我也知道你的挑剔,但我就是我,不一样的烟火,谢谢你的指指点点,造就了我的点点滴滴:)!



二十四桥明月夜,玉人何处教吹箫?


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值