Analytics工具如何准确提供referer?

How do Analytics tool provide referer accurately?

正如 and 中指出的那样,PHP 的 $_SERVER["HTTP_REFERER"] 和 Javascript 的 document.referer 可以为空,尤其是在 HTTPS 的情况下请求。

例如,来自 https://github.com/ 的流量为我提供了一个包含 PHP 和 JS 方法的空白字符串。

Google 分析(或其他分析工具)如何准确记录引荐来源网址,例如在 https://github.com 引荐来源网址的情况下?

注意:这不是前面提到的问题的重复问题,这里的问题是研究分析工具(例如Google Analytics)如何做到这一点(可能非常聪明的方式)。

为了让您了解上下文,在 Google 中,Analytics(通用 JS)由以下函数设置:

function(a) {
            var b = I.referrer;   //I equals documents
            if (/^https?:\/\//i.test(b)) { //check if b.referrer is a page
                if (a) return b; // "A" is the value to force to always send the referer
                a = "//" + I.location.hostname; //extract the actual location
                var c = b.indexOf(a);
                if (5 == c || 6 == c)
                    if (a = b.charAt(c + a.length), "/" == a || "?" == a || "" == a || ":" == a) return;
              //if this is not the same, return null, in other hands returns the referral domain
                return b
            }

如您所见,唯一使用的资源是 document.referrer。所以这是空的,没有什么可做的。这是在您可以编辑 link(手动确定源)

时使用 UTM 参数的原因之一

现在由于安全原因 HTTPs 将不会传递引用,所以可能使用 URL 中的参数看起来是最好的解决方案(由您复制 UTM)