单击 link 时如何跟踪?

How do I track when a link is clicked?

在我的网站上,我想跟踪广告点击并奖励用户。基本上是 PayPerClick。当用户单击 AD 或 Link 时,我想增加他们拥有的点数。有没有简单的方法可以做到这一点?

我猜我将不得不为此使用 javascript。

dbeas.com

以下代码将帮助您入门。

看看这个 fiddle

这是片段。

var points = 0;

$("a.ad").click(function() {
  points++;
  //send point to server
  //tell the user about the increase in points
  alert(points);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class='ad' target='_blank' href='http://www.google.com'> This is Ad</a>
<br>
<a target='_blank' href='http://www.google.com'> This is Not an Ad</a>