如何判断Web客户端是否阻止广告?

时间:2022-12-04 15:51:15

What is the best way to record statistics on the number of visitors visiting my site that have set their browser to block ads?

记录访问我网站的访问者数量的最佳方法是将浏览器设置为阻止广告?

5 个解决方案

#1


11  

Since programs like AdBlock actually never request the advert, you would have to look the server logs to see if the same user accessed a webpage but didn't access an advert. This is assuming the advert is on the same server.

由于像AdBlock这样的程序实际上从不请求广告,因此您必须查看服务器日志以查看同一用户是否访问了网页但未访问广告。这假设广告在同一台服务器上。

If your adverts are on a separate server, then I would suggest it's impossible to do so.

如果您的广告位于单独的服务器上,那么我建议不可能这样做。

The best way to stop users from blocking adverts, is to have inline text adverts which are generated by the server and dished up inside your html.

阻止用户阻止广告的最佳方法是使用由服务器生成并在html中抛出的内联文本广告。

#2


10  

Add the user id to the request for the ad:

将用户ID添加到广告请求中:

<img src="./ads/viagra.jpg?{user.id}"/>

that way you can check what ads are seen by which users.

这样,您就可以查看哪些用户看到了哪些广告。

#3


4  

You need to think about the different ways that ads are blocked. The first thing to look at is whether they are running noscript, so you could add a script that would check for that.

您需要考虑广告被阻止的不同方式。首先要看的是它们是否正在运行noscript,因此您可以添加一个可以检查该脚本的脚本。

The next thing is to see if they are blocking flash, a small movie should do that.

接下来就要看看它们是否阻挡闪光灯,一部小电影应该这样做。

If you look at the adblock site, there is some indication of how it does blocking:
How does element hiding work?

如果您查看adblock网站,可以看出它是如何阻止的:元素隐藏如何工作?

If you look further down that page, you will see that conventional chrome probing will not work, so you need to try and parse the altered DOM.

如果你向下看那个页面,你会发现传统的chrome探测不起作用,所以你需要尝试解析改变后的DOM。

#4


4  

AdBlock forum says this is used to detect AdBlock. After some tweaking you could use this to gather some statistics.

AdBlock论坛称这用于检测AdBlock。经过一些调整后,您可以使用它来收集一些统计数据。

setTimeout("detect_abp()", 10000);
var isFF = (navigator.userAgent.indexOf("Firefox") > -1) ? true : false,
    hasABP = false;

function detect_abp() {
  if(isFF) {
    if(Components.interfaces.nsIAdblockPlus != undefined) {
      hasABP = true;
    } else {
      var AbpImage = document.createElement("img");
      AbpImage.id = "abp_detector";
      AbpImage.src = "/textlink-ads.jpg";
      AbpImage.style.width = "0";
      AbpImage.style.height = "0";
      AbpImage.style.top = "-1000px";
      AbpImage.style.left = "-1000px";
      document.body.appendChild(AbpImage);
      hasABP = (document.getElementById("abp_detector").style.display == "none");

      var e = document.getElementsByTagName("iframe");
      for (var i = 0; i < e.length; i++) {
        if(e[i].clientHeight == 0) {
          hasABP = true;
        }
      }
      if(hasABP == true) {
        history.go(1);
        location = "http://www.tweaktown.com/supportus.html";
        window.location(location);
      }
    }
  }
}

#5


3  

I suppose you could compare the ad prints with the page views on your website (which you can get from your analytics software).

我想您可以将广告打印与网站上的网页浏览量进行比较(您可以从分析软件中获取)。

#1


11  

Since programs like AdBlock actually never request the advert, you would have to look the server logs to see if the same user accessed a webpage but didn't access an advert. This is assuming the advert is on the same server.

由于像AdBlock这样的程序实际上从不请求广告,因此您必须查看服务器日志以查看同一用户是否访问了网页但未访问广告。这假设广告在同一台服务器上。

If your adverts are on a separate server, then I would suggest it's impossible to do so.

如果您的广告位于单独的服务器上,那么我建议不可能这样做。

The best way to stop users from blocking adverts, is to have inline text adverts which are generated by the server and dished up inside your html.

阻止用户阻止广告的最佳方法是使用由服务器生成并在html中抛出的内联文本广告。

#2


10  

Add the user id to the request for the ad:

将用户ID添加到广告请求中:

<img src="./ads/viagra.jpg?{user.id}"/>

that way you can check what ads are seen by which users.

这样,您就可以查看哪些用户看到了哪些广告。

#3


4  

You need to think about the different ways that ads are blocked. The first thing to look at is whether they are running noscript, so you could add a script that would check for that.

您需要考虑广告被阻止的不同方式。首先要看的是它们是否正在运行noscript,因此您可以添加一个可以检查该脚本的脚本。

The next thing is to see if they are blocking flash, a small movie should do that.

接下来就要看看它们是否阻挡闪光灯,一部小电影应该这样做。

If you look at the adblock site, there is some indication of how it does blocking:
How does element hiding work?

如果您查看adblock网站,可以看出它是如何阻止的:元素隐藏如何工作?

If you look further down that page, you will see that conventional chrome probing will not work, so you need to try and parse the altered DOM.

如果你向下看那个页面,你会发现传统的chrome探测不起作用,所以你需要尝试解析改变后的DOM。

#4


4  

AdBlock forum says this is used to detect AdBlock. After some tweaking you could use this to gather some statistics.

AdBlock论坛称这用于检测AdBlock。经过一些调整后,您可以使用它来收集一些统计数据。

setTimeout("detect_abp()", 10000);
var isFF = (navigator.userAgent.indexOf("Firefox") > -1) ? true : false,
    hasABP = false;

function detect_abp() {
  if(isFF) {
    if(Components.interfaces.nsIAdblockPlus != undefined) {
      hasABP = true;
    } else {
      var AbpImage = document.createElement("img");
      AbpImage.id = "abp_detector";
      AbpImage.src = "/textlink-ads.jpg";
      AbpImage.style.width = "0";
      AbpImage.style.height = "0";
      AbpImage.style.top = "-1000px";
      AbpImage.style.left = "-1000px";
      document.body.appendChild(AbpImage);
      hasABP = (document.getElementById("abp_detector").style.display == "none");

      var e = document.getElementsByTagName("iframe");
      for (var i = 0; i < e.length; i++) {
        if(e[i].clientHeight == 0) {
          hasABP = true;
        }
      }
      if(hasABP == true) {
        history.go(1);
        location = "http://www.tweaktown.com/supportus.html";
        window.location(location);
      }
    }
  }
}

#5


3  

I suppose you could compare the ad prints with the page views on your website (which you can get from your analytics software).

我想您可以将广告打印与网站上的网页浏览量进行比较(您可以从分析软件中获取)。