token拦截器阻止连接_如何防止广告拦截器阻止您的分析数据
token拦截器阻止连接
TL;DR There's dataunlocker.com service coming soon (subscribe!), along with the open-sourced prototype you can use for Google Analytics or Google Tag Manager (2020 update).
TL; DR即将推出dataunlocker.com服务 (订阅!),以及可用于Google Analytics(分析)或Google Tag Manager(2020更新)的开源原型 。
TL;DR There's dataunlocker.com service coming soon (subscribe!), along with the open-sourced prototype you can use for Google Analytics or Google Tag Manager (2020 update).The article from 2017s below explains the used principles behind these solutions, as well as it is described in the solution's readme.
TL; DR即将推出(订阅!) dataunlocker.com服务 ,以及可用于Google Analytics(分析)或Google 跟踪代码管理器(2020更新)的开源原型 。 下面的2017年代文章解释了这些解决方案背后的使用原理,并在解决方案的自述文件中进行了描述。
When your product is just getting started out, every single user matters. So does the data about how they interact with your product.
当您的产品刚刚入门时,每个用户都很重要。 有关它们如何与您的产品交互的数据也是如此。
If you’ve tried using analytics solutions like Google Analytics, you may have faced an issue where your analytics collection was blocked by ad blockers.
如果您尝试使用Google Analytics(分析)之类的分析解决方案,则可能会遇到一个问题,即广告拦截器阻止了您的分析集合。
According to PageFair, up to 30% of Internet users use ad blockers in 2017, and this number is constantly growing.
根据PageFair的调查 , 2017年 , 多达30%的互联网用户使用广告拦截器,并且这一数字还在不断增长。
This article will explain some technical approaches you can take to prevent ad blockers from also blocking your analytics. We’ll use Google Analytics in this article, though much of this could be applied to other analytics tools.
本文将介绍一些可用来防止广告拦截程序也阻止您的分析的技术方法。 我们将在本文中使用Google Analytics(分析) ,尽管其中许多可以应用于其他分析工具。
您可以通过一些方法绕过广告拦截器 (Some ways you can bypass ad blockers)
Almost all ad blockers work through the same methods: they disallow some http(s) browser requests for content at URLs that match a certain mask from their filtering base.
几乎所有广告拦截器都通过相同的方法工作:它们禁止某些http(s)浏览器对URL上与其过滤基础中的特定掩码匹配的URL的内容的请求。
Most ad blockers blacklist www.google-analytics.com by default, and block any attempts by the Google Analytics JavaScript library to send or retrieve the data from its analytics servers.
大多数广告拦截器默认都会将www.google-analytics.com列入黑名单,并阻止Google Analytics(分析)JavaScript库从其分析服务器发送或检索数据的任何尝试。
Luckily for developers, ad blockers don’t block requests to our own domain names by default, because doing this may hurt the web application’s functionality. This gap reveals a way to avoid analytics blocking until your web service become well-known enough for some of its URLs appear in ad blocker filters.
幸运的是,对于开发人员而言,广告拦截器默认情况下不会拦截对我们自己域名的请求,因为这样做可能会损害Web应用程序的功能。 这种差距揭示了一种方法,可以避免分析阻塞,直到您的Web服务众所周知,使其某些URL出现在广告阻止程序过滤器中为止。
In fact, even after some URLs appear in the content filtering base, you can start playing with ad blockers by inventing terrible things, such as hourly changing analytics URLs (though this is beyond the scope of this article). Some of these approaches are applied by services like DataUnlocker.com and Adtoniq, which offer users adblocker-free experience even when ad blockers are turned on.
实际上,即使某些URL出现在内容过滤基础中,您也可以通过发明糟糕的事情(例如每小时更改一次的分析URL)来开始使用广告拦截器(尽管这不在本文讨论范围之内)。 其中的一些方法由DataUnlocker.com和Adtoniq等服务应用,即使打开了广告拦截器,该服务也可以为用户提供无广告拦截器的体验。
对我们将要做什么的高级解释 (A high-level explanation of what we’re going to do)
In this article, we’ll assume that we have no permission restrictions on the server side. We will write the demo solution (a few lines of code) for the Node.js platform. Once you understand how this works, you should be able to port this solution to any programming language or platform.
在本文中,我们假设服务器端没有权限限制。 我们将为Node.js平台编写演示解决方案(几行代码)。 了解了它的工作原理后,您应该可以将此解决方案移植到任何编程语言或平台上。
The solution I’ll describe is pretty minimal, and if you’re an experienced web developer, it may only take you a few minutes to put it in place.
我将介绍的解决方案非常少,如果您是一位经验丰富的Web开发人员,则只需几分钟即可将其安装到位。
We’re going to use a simple proxying approach without the need to diving into the Google Analytics measurement protocol. In short, the solution looks as following:
我们将使用一种简单的代理方法,而无需深入研究Google Analytics(分析)测量协议 。 简而言之,解决方案如下所示:
First, download the Google Analytics JavaScript library itself and host it on your server.
首先, 下载 Google Analytics(分析)JavaScript库本身,并将其托管在您的服务器上。
Then alter the code in the downloaded library to change the target host from www.google-analytics.com to your own domain name using find-replace.
然后更改下载的库中的代码,以使用find-replace将目标主机从www.google-analytics.com更改为您自己的域名。
- Replace the link from the default Google Analytics script in your codebase to modified one.将代码库中默认Google Analytics(分析)脚本中的链接替换为已修改的链接。
Create a proxy endpoint to Google Analytics servers on your back end. One important step here is to additionally detect the client’s IP address and write it explicitly in requests to Google Analytics servers to preserve correct location detection.
在后端创建指向Google Analytics(分析)服务器的代理端点。 此处的一个重要步骤是另外检测客户端的IP地址,并将其显式写入Google Analytics(分析)服务器的请求中,以保留正确的位置检测。
- Test the results. You’re done!测试结果。 你完成了!
完整的技术实施演练 (The full technical implementation walkthrough)
All the code and described steps below are available on GitHub. The description below explains the method basics, and of course the suggested approach can be improved to be even more “anti-blocking.”
GitHub上提供了下面的所有代码和描述的步骤。 下面的描述说明了方法的基本原理,当然,可以将建议的方法进行改进,使其更加“防阻塞”。
In Google Analytics, you start by acquiring a unique tracking ID for your property (web service). We will use UA-98253329–1 tracking ID in this article for the demonstration. Don’t forget to replace the tracking code to your one.
在Google Analytics(分析)中,您首先需要获取媒体资源(网络服务) 的唯一跟踪ID 。 在本文中,我们将使用UA-98253329–1跟踪ID进行演示。 不要忘记将跟踪代码替换为您的跟踪代码。
Google suggests adding this minified code to your web services to enable analytics:
Google建议将此精简代码添加到您的网络服务中以启用分析:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script',
'https://www.google-analytics.com/analytics.js','ga');ga('create', 'UA-98253329-1', 'auto');ga('send', 'pageview');
</script>
In a few words, this code loads the Google Analytics JavaScript library if it wasn’t loaded before by inserting the script tag to the document. This library includes all the logic of analytics collection, and it is the only thing we need to proceed.
简而言之,如果之前未加载此代码,则可以通过将script标记插入文档中来加载Google Analytics(分析)JavaScript库。 该库包含分析收集的所有逻辑,这是我们唯一需要进行的工作。
步骤1:下载并修补Google的分析库 (Step 1: Download and patch Google’s analytics library)
Download the script directly from https://www.google-analytics.com/analytics.js, open it with any text editor and replace all occurrences of:
直接从https://www.google-analytics.com/analytics.js下载脚本,使用任何文本编辑器将其打开,并替换所有出现的内容:
www.google-analytics.com
with this exact string:
使用这个确切的字符串:
"+location.host+"/analytics
By patching the analytics library in this way, it will start making requests to the local host (my.domain.com/analytics) endpoints instead of www.google-analytics.com. Place this patched analytics.js file on your server after the replacement.
通过以这种方式修补分析库,它将开始向本地主机( my.domain.com/analytics)端点而不是www.google-analytics.com发出请求。 替换后,将此修补的analytics.js文件放置在您的服务器上。
步骤2:用已修补的脚本替换分析脚本 (Step 2: Replace the analytics script with the patched one)
Let’s modify the Google Analytics embedding code in that way so it use our patched library instead of default one:
让我们以这种方式修改Google Analytics(分析)嵌入代码,以便它使用我们的修补库而不是默认库:
<script>
(function(i,s,o,r){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date()})(window,document,'script','ga');ga('create', 'UA-98253329-1', 'auto');ga('send', 'pageview');
</script>
<script src="/analytics.js" async></script>
Note that here browser will search for the patched analytics script in the document root of your server, in this case, my.domain.com/analytics.js. Check whether you put the script in the document root or changed the path in script tag above. You can also check the results by running a test on your local server (see the readme for how to run the GitHub example).
请注意,此处浏览器将在服务器的文档根目录(本例中为my.domain.com/analytics.js)中搜索已修补的分析脚本。 检查是否将脚本放在文档根目录中或更改了上面脚本标签中的路径。 您还可以通过在本地服务器上运行测试来检查结果(有关如何运行GitHub示例的信息,请参见自述文件 )。
You should see something like this in browser’s developer tools:
您应该在浏览器的开发人员工具中看到以下内容:
Ultimately we want the act of downloading your patched analytics.js to return a successful response — a 200 (OK) or a 304 (not modified) status. But at this point, the request to my.domain.com/analytics/collect should respond with 404 status, since we haven’t implemented the proxy server yet.
最终,我们希望下载修补后的analytics.js的操作返回成功的响应,即200(确定)或304(未修改)状态。 但是在这一点上,对my.domain.com/analytics/collect的请求应以404状态响应,因为我们尚未实现代理服务器。
步骤3:实现最简单的代理服务器 (Step 3: Implementing the Simplest Proxy Server)
Now we’re going to code a bit. Our goal is to implement the proxy server, which will transport our analytics requests from our server to the real Google Analytics server. We can do this in many ways, but as an example, let’s use Node.js and Express.js with the express-http-proxy package.
现在我们要编写一些代码。 我们的目标是实现代理服务器 ,该代理服务器会将我们的分析请求从我们的服务器传输到真正的Google Analytics(分析)服务器。 我们可以通过多种方式来执行此操作,但作为示例,让我们将Node.js和Express.js与express-http-proxy包一起使用。
Gathering all the files in the example together (see GitHub), we should end up with the following JavaScript server code:
一起收集示例中的所有文件( 请参阅GitHub ),我们应该以以下JavaScript服务器代码结束:
var express = require("express"), proxy = require("express-http-proxy"), app = express();app.use(express.static(__dirname)); // serve static files from cwdfunction getIpFromReq (req) { // get the client's IP addressvar bareIP = ":" + ((req.connection.socket && req.connection.socket.remoteAddress)|| req.headers["x-forwarded-for"] || req.connection.remoteAddress || "");return (bareIP.match(/:([^:]+)$/) || [])[1] || "127.0.0.1";
}// proxying requests from /analytics to www.google-analytics.com.
app.use("/analytics", proxy("www.google-analytics.com", {proxyReqPathResolver: function (req) {return req.url + (req.url.indexOf("?") === -1 ? "?" : "&")+ "uip=" + encodeURIComponent(getIpFromReq(req));}
}));app.listen(1280);
console.log("Web application ready on http://localhost:1280");
A few last lines here do the proxying. The only trick we do here is instead of just proxying, we detect and append the client’s IP address explicitly in a form of a measurement protocol URL parameter. This is required to collect precise location data, because all the requests to Google Analytic originally come from our server’s IP address, which remains constant.
最后几行进行代理。 我们在这里做的唯一技巧不仅仅是代理,我们还以度量协议URL参数的形式显式检测并附加客户端的IP地址。 这是收集精确位置数据所必需的,因为对Google Analytic的所有请求最初都来自我们服务器的IP地址,该IP地址保持不变。
After setting up our server proxy, we can check whether the request to our /collect endpoint now successfully returns a 200 OK HTTP status:
设置服务器代理后,我们可以检查对/ collect端点的请求现在是否成功返回200 OK HTTP状态:
We can use, for example, an anonymous connection to verify that location is also picked up correctly.
例如,我们可以使用匿名连接来验证是否也正确提取了位置。
This “proxy server” approach is a fast workaround for analytics that enables your services to avoid ad blockers. But this method relies on the browser side, and if the browser script for some reason does not send analytics information to our servers, we get nothing.
这种“代理服务器”方法是一种快速的分析方法,可帮助您的服务避免广告拦截。 但是这种方法依赖于浏览器端,并且如果浏览器脚本由于某种原因没有将分析信息发送到我们的服务器,我们将一无所获。
The last possible step if you want to implement a solid solution is to send analytics directly from the server by using server-side libraries available for different languages (NodeJS, Python, Ruby, PHP). This approach will definitely avoid any content blockers, as every request to analytics servers comes directly from our servers.
如果要实现可靠的解决方案,最后一个可能的步骤是使用适用于不同语言( NodeJS , Python , Ruby , PHP )的服务器端库直接从服务器发送分析。 这种方法肯定会避免任何内容阻止,因为对分析服务器的每个请求都直接来自我们的服务器。
Again, the demo application is available on GitHub, feel free to test it! Let me know if you have any feedback or interesting experiences using this approach.
同样,该演示应用程序可在GitHub上使用 ,请随时对其进行测试! 如果您有任何反馈或使用此方法的有趣经历,请告诉我。
Thanks for reading!
谢谢阅读!
翻译自: https://www.freecodecamp.org/news/save-your-analytics-from-content-blockers-7ee08c6ec7ee/
token拦截器阻止连接
相关文章:

使用Fiddler手机抓包https-----重要
Fiddler不仅可以对手机进行抓包,还可以抓取别的电脑的请求包,今天就想讲一讲使用Fiddler手机抓包! 使用Fiddler手机抓包有两个条件: 一:手机连的网络或WiFi必须和电脑(使用fiddler)连的网络或Wi…

strtok和strtok_r
strtok和strtok_r原型:char *strtok(char *s, char *delim); 功能:分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。 说明:首次调用时,s指向要分解的字符串,之后再次调用要把s设成NULL。 …

iOS 标签自动布局
导入SKTagFrame SKTagFrame *frame [[SKTagFrame alloc] init];frame.tagsArray self.bigModel.Tags;// 添加标签CGFloat first_H 0;CGFloat total_H 0;for (NSInteger i 0; i< self.bigModel.Tags.count; i) {UIButton *tagsBtn [UIButton buttonWithType:UIButtonT…

引导分区 pbr 数据分析_如何在1小时内引导您的分析
引导分区 pbr 数据分析by Tim Abraham蒂姆亚伯拉罕(Tim Abraham) 如何在1小时内引导您的分析 (How to bootstrap your analytics in 1 hour) Even though most startups understand how critical data is to their success, they tend to shy away from analytics — especial…

SSL 1460——最小代价问题
Description 设有一个nm(小于100)的方格(如图所示),在方格中去掉某些点,方格中的数字代表距离(为小于100的数,如果为0表示去掉的点),试找出一条从A(左上角)到B(右下角&am…

在Windows 7下面IIS7的安装和 配置ASP的正确方法
在Windows 7下如何安装IIS7,以及IIS7在安装过程中的一些需要注意的设置,以及在IIS7下配置ASP的正确方法。 一、进入Windows 7的 控制面板,选择左侧的打开或关闭Windows功能 。二、打开后可以看到Windows功能的界面,注意选择的项目…

适配iOS 13 tabbar 标题字体不显示以及返回变蓝色的为问题
// 适配iOS 13 tabbar 标题字体不显示以及返回变蓝色的为问题 if (available(iOS 13.0, *)) {//[[UITabBar appearance] setUnselectedItemTintColor:Color_666666];}

企业不要求工程师资格认证_谁说工程师不能成为企业家?
企业不要求工程师资格认证by Preethi Kasireddy通过Preethi Kasireddy 谁说工程师不能成为企业家? (Who says engineers can’t become entrepreneurs?) A lot of people warned me not to walk away from my great position at Andreessen Horowitz to pursue so…

BestCoder Round #92 比赛记录
上午考完试后看到了晚上的BestCoder比赛,全机房都来参加 感觉压力好大啊QAQ,要被虐了. 7:00 比赛开始了,迅速点进了T1 大呼这好水啊!告诉了同桌怎么看中文题面 然后就开始码码码,4分16秒AC了第一题 7:05 开始看第二题 诶诶诶!!~~~~直接爆搜不久能过吗? 交了一发爆搜上去,AC了,…

[cocos2dx UI] CCLabelAtlas 为什么不显示最后一个字
CClabelAtlas优点,基本用法等我就不说了,这里说一个和美术配合时的一个坑!就是图片的最后一位怎么也不显示,如下图中的冒号不会显示 查了ASCII码表,这个冒号的值为58,就是在9(57)的后…

iOS 13 适配TextField 崩溃问题
iOS 13 之后直接通过以下方式修改Textfield的时候会出现报错信息 [_accountText setValue:Color_666666 forKeyPath:"_placeholderLabel.textColor"]; 报错信息 Access to UITextField’s _placeholderLabel ivar is prohibited. This is an application bug 解决…

测试django_如何像专业人士一样测试Django Signals
测试djangoby Haki Benita通过Haki Benita 如何像专业人士一样测试Django Signals (How to test Django Signals like a pro) For a better reading experience, check out this article on my website.为了获得更好的阅读体验,请在我的网站上查看此文章 。 Djang…

C#中静态方法的运用和字符串的常用方法(seventh day)
又来到了今天的总结时间,由于昨天在云和学院学的知识没有弄懂,今天老师又专门给我们非常详细地讲了一遍,在这里非常谢谢老师。O(∩_∩)O 话不多说,下面就开始为大家总结一下静态方法的运用和字符串的常用方法。 理论:静…

raid 磁盘阵列
mkdir /uuu #建挂载目录echo "- - -" > /sys/class/scsi_host/host2/scan #扫描新硬盘 lsblk #查看 parted /dev/sdb #分区 parted /dev/sdc lsblk mdadm -Cv /dev/md1 -l1 -n2 -c128 /dev/sd[b,c]1 #raid1配置, /dev/md1名字&#…

iOS 13 如何删除SceneDelegate
Xcode11之后新创建的工程会多出两个文件SceneDelegate。那么我们如何让它变回之前的那样的工程呢。 一、将这两个文件删除。 会报错There is no scene delegate set. A scene delegate class must be specified to use a main storyboard file. 二、将Info.plist 中的 SceneMai…

女性程序员大会ghc_在女性科技大会上成为男人的感觉
女性程序员大会ghcby Elijah Valenciano通过伊莱贾瓦伦西亚诺 在女性科技大会上成为男人的感觉 (What It’s Like to be a Man at a Women’s Tech Conference) To be honest, I was very nervous. A few panicked thoughts started to flood my mind as I prepared myself to…

cf776G.Sherlock and the Encrypted Data
题意:对于一个16进制数x,把x的各个数位拿出来,设其为t1,t2,...,定义s(x)为2^t1|2^t2|...,如x0x3e53,则s(x)2^3|2^14|2^5|2^316424.给出q组询问l,r(l,r也是16进制数,不超过15位),求[l,r]中有多少个数x满足x^s(x)<x. 这题题解写的是个状压数位dp,但是蒟蒻不会数位dp,自己YY了一…

c++, 派生类的构造函数和析构函数 , [ 以及operator=不能被继承 or Not的探讨]
说明:文章中关于operator实现的示例,从语法上是对的,但逻辑和习惯上都是错误的。 参见另一篇专门探究operator的文章:《c,operator》http://www.cnblogs.com/mylinux/p/4113266.html 1.构造函数与析构函数不会被继承&a…

json转换模型利器--JSONExport
JSONExport 从json 到 Model ,如此的方便 swift oc java 全部支持

亚马逊ses如何发qq_使用Amazon SES发送电子邮件
亚马逊ses如何发qqby Kangze Huang黄康泽 使用Amazon SES发送电子邮件 (Sending emails with Amazon SES) 完整的AWS Web样板-教程3 (The Complete AWS Web Boilerplate — Tutorial 3) 目录 (Table of Contents) Part 0: Introduction to the Complete AWS Web Boilerplate第…

源码-0205-02--聊天布局
还真是失败,搞了两天遇到了布局cell高度总是出差的问题,cell height不是高很多很多,就是就是矮到没有的情况。。。。糟糕透顶待解救~ 聊天布局 // // XMGChatingViewController.m // 07-聊天布局 #import "XMGChatingViewC…

js实现页面跳转的几种方式
第一种:<script language"javascript" type"text/javascript"> window.location.href"login.jsp?backurl"window.location.href; </script>第二种: <script language"javascript&q…

Mac 升级系统 pod 命令无效
mac 升级完最新的系统之后 使用pod 命令之后无效报错 -bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory 解决方案 sudo gem install -n /usr/local/bin cocoapods

node seneca_使用Node.js和Seneca编写国际象棋微服务,第1部分
node seneca(This is Part 1 of a three-part series [Part 2, Part 3])(这是一个由三部分组成的系列文章的第1部分[ 第2 部分 , 第3部分 ]) I’ve begun wrapping my head around microservices. Up to this time I regarded it as a scalability pattern and ove…

Ubuntu中基于QT的系统网线连接状态的实时监视
1.必要准备 需包: #include <QNetworkInterface> 2.实现获取当前的网线连接状态 以下是自己在网络上搜到的一个解决方法,且没有加入iface.flags().testFlag(QNetworkInterface::IsRunning) 这一逻辑判断,经测试实时性极不可靠ÿ…

iOS 开发者账号 到期续费问题
https://blog.csdn.net/liruiqing520/article/details/104043221

[转载]Using ngOptions In AngularJS
http://odetocode.com/blogs/scott/archive/2013/06/19/using-ngoptions-in-angularjs.aspx?utm_sourcetuicool转载于:https://www.cnblogs.com/Benoly/p/4097213.html

graphql_GraphQL的稳步上升
graphqlToday GitHub announced that the next version of their API will use a new technology developed by Facebook called GraphQL.今天,GitHub宣布其API的下一版本将使用Facebook开发的一项名为GraphQL的新技术。 GraphQL may eventually come to replace t…

转: windows系统下mysql出现Error 1045(28000) Access Denied for user 'root'@'localhost'
windows系统下mysql出现Error 1045(28000) Access Denied for user rootlocalhost 转自 http://zxy5241.spaces.live.com/blog/cns!7682A3008CFA2BB0!361.entry 在windows操作系统安装MySQL数据库,碰到Error 1045(28000) Access Denied for user rootlocalhost 错误…

正则表达式的字符、说明和其简单应用示例
字符和其含义 字符 含义 \ 转义字符,将一个具有特殊功能的字符转义为一个普通的字符 ^ 匹配字符串的开始位置 $ 匹配字符串的结束位置 * 匹配前面的0次或多次的子表达式 …