如何使用 Afilter Tracker 事件追踪 Google Adsense点击
本篇文章向您介绍如果使用 Afilter Tracker 事件追踪 Google Adsense 点击
Afilter Tracker 事件追踪可以实现很多功能,比如说谷歌广告点击数。配合事件追踪,用户可以有效的检测出流量质量。
设置追踪事件
示例代码
以下为追踪示例代码
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Afilter Tracker Google 广告点击追踪演示</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
var isOverGoogleAd = false;
var ad = /adsbygoogle/;
$(document).ready(function()
{
$('ins').on('mouseover', function () {
if(ad.test($(this).attr('class'))){
isOverGoogleAd = true;
}
});
$('ins').on('mouseout', function () {
if(ad.test($(this).attr('class'))){
isOverGoogleAd = false;
}
});
});
$(window).blur(function(e){
if(isOverGoogleAd){
$.ajax({
type: "POST",
url: "https://afilter.xyz/p/events",
data: {"et":1},
xhrFields: {withCredentials: true},
crossDomain: true,
});
}
});
</script>
</head>
<body>
<script async src='//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'></script>
<!-- qym -->
<ins class='adsbygoogle'
style='display:inline-block;width:970px;height:90px'
data-ad-client='ca-pub-111111111111111'
data-ad-slot='1111111111'></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</body>
</html>
Updated over 6 years ago