使用PHP跟踪Web流量 [英] Track Web Traffic with PHP

查看:271
本文介绍了使用PHP跟踪Web流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在使用PHP跟踪网络流量(或至少网络流量来源)的有效方法?

我当时正在考虑为每个搜索引擎和其他网站使用自定义规范链接,这意味着任何不带参数访问mywebsite.com的人都可能是直接流量.但是然后我需要以某种方式为每个引擎搜寻器更改link rel='canonical'元素的href值(例如https://mywebsite.com/?ref=googlehttps://mywebsite.com/?ref=duckduckgo等),而我不确定如何做到这一点(通过robots.txt,meta标记还是?).

I was thinking of using custom canonical links for each search engine and other websites, which would mean anybody who visits mywebsite.com without a parameter is likely direct traffic. But then I would somehow need to change the href value of the link rel='canonical' element for each engine crawler (e.g. https://mywebsite.com/?ref=google, https://mywebsite.com/?ref=duckduckgo, etc), and I'm not exactly sure how to go about this (through robots.txt, meta tags or?).

如果没有必要,我真的不想使用Google Analytics(分析).可以这么说,我宁愿将所有分析都放在一个屋檐下,但是我对如何实现这一目标抱有想法,而且我在SO上进行的大多数搜索似乎都拉动了与GA相关的工作.

I really don't want to use Google Analytics if I don't have to. I'd prefer to have all of my analytics under one roof so to speak, but I'm stuck for ideas of how to achieve this, and most of my searches on SO seem to pull up stuff related GA.

推荐答案

我从头到尾都读了有关头文件在很多情况下的情况,由于各种原因(例如AV软件,浏览器扩展,从http切换到https等)而被省略了吗?经常是这种情况吗?

well ive read all over SO about how in many cases the header can be and is simply omitted for various reasons such as AV software, browser extensions, switching from http to https, etc? is this often the case?

是的,这可能发生.任何人都对您的特定站点的访问者来说多久一次.

Yes, this can happen. How often for your particular site's visitors is anyone's guess.

GA是否依赖引荐来源标头?

does GA rely on the referer header?

不太...由于Google Analytics(分析)在客户端运行,它是从document.referrer获取该信息的,它包含与Referer标头中发送的信息相同的值.

Not quite... as Google Analytics runs client-side, it's getting that information from document.referrer, which contains the same value as what is sent in the Referer header.

但是我当然希望数字尽可能准确

but i would of course like to have numbers that are as accurate as possible

使用任何网络分析,您都无法衡量某些事情.最好的方法是使用客户端分析脚本将数据发送到服务器.这样做有很多原因,比单纯查看您在PHP的HTTP请求数据中获得的数据要好:

With any web analytics, there are things you simply can't measure. The best way is to use a client-side analytics script to send data to your server. There are a handful of reasons why this is better than simply looking at the data you get in the HTTP request data in PHP:

  • 页面可以缓存,因此您甚至可以在浏览器甚至从未与服务器签入加载页面的情况下看到页面加载.
  • Performance API 可用,您可以跟踪可以逐步改善的特定加载时间.
  • 在大多数浏览器中,您可以使用 Beacon API 了解用户何时离开页面,从而获得准确的页面停留时间测量.
  • Pages can be cached, so you'll be able to see page loads at times when the browser never even checked in with your server to load the page.
  • The Performance API is available, allowing you to track specific load timings that you can work to improve on over time.
  • In most browsers, you can use the Beacon API to get a sense for when the user leaves the page, so you have accurate time-on-page measurements.

我想了解什么是直接流量,什么不是直接流量以及非直接流量来自何处

id like to get an idea of what traffic is direct and what traffic is not direct and where non-direct traffic is coming from

document.referrer是您想要的,并且使您尽可能地接近准确.

document.referrer is what you want, and gets you as close to accurate as you can get.

这篇关于使用PHP跟踪Web流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆