简体   繁体   English

跟踪外部链接的点击

[英]tracking clicks on external link

I have an external link which links to my site and i would like to track the number of clicks on that link. 我有一个链接到我的网站的外部链接,我想跟踪该链接的点击次数。

One way to do it without using google analytics is to use ajax as mentioned in this post : How do I keep track of how many times an external link is clicked? 一种无需使用Google Analytics(分析)的方法是使用ajax(如本文所述): 如何跟踪外部链接被点击了多少次? (See the first response) (请参阅第一个回复)

But if I use JavaScript the number of clicks can easily be faked. 但是,如果我使用JavaScript,则点击次数很容易被伪造。 What is the best way to prevent this? 预防这种情况的最佳方法是什么?

Edit: sorry I didn't make my question clear. 编辑:对不起,我没有清楚我的问题。 Just like the like button in fb for instance, the user who visits my site can get a link (which he/she has to copy/paste) and the link will point to my site. 就像fb中的“赞”按钮like ,访问我的网站的用户可以获得一个链接(他/她必须复制/粘贴),该链接将指向我的网站。

You could implement a server side script is a middleware that logs the click before it redirects. 您可以实现一个服务器端脚本,该脚本是一种中间件,可以在点击之前记录重定向。

Eg you have a simple PHP script like this: 例如,您有一个简单的PHP脚本,如下所示:

<?php
$url = $_GET['url'];
$logger->logHit($url);
header("Location: ".$url);
?>

Then you link would be something like this: 然后您将链接如下所示:

http://yoursite.com?url=http://external.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM