PHP 和 MySQL 中的短 URL 出站链接跟踪

发布于 2024-09-09 23:39:57 字数 362 浏览 11 评论 0原文

我有一个基于 Noah Hendrix 的缩短链接的网站关于该主题的教程。我认为如果我能够跟踪用户何时点击短 URL,那就太好了,类似于 HootSuite 用户可以使用 Owly 跟踪他们的链接。我目前有一个数据库,其中存储了短网址以及真实网址及其点击次数。理想情况下,当外部用户访问该短 URL 时,点击计数列将会更新。

简而言之,我正在寻找一个 PHP/MySQL 解决方案来跟踪各种短 URL 的点击次数。任何可以从点击中收集的附加信息也将不胜感激。

I have a site that shortens links based on Noah Hendrix's tutorial on the subject. I decided that it would be great if I could track when users click the short URLs, similar to the way that HootSuite users can track their links with Owly. I currently have a database which has the short URL stored along with the true URL and it's click count. Ideally the click count column would update when that short URL is accessed by an outside user.

In short, I am looking for a PHP/MySQL solution to keep track of the number of times various short URLs are clicked. Any additional information that could be gathered from the clicks would be greatly appreciated as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缺⑴份安定 2024-09-16 23:39:57

我假设您遵循了他的教程的 php 版本。如果是这样,请查看“服务短 URL”下的serve.php 列表。在第 11 行设置 301 状态的部分中,您可以在那里记录重定向以及对数据库的更新。类似的事情

 $query = mysql_query("update `".$database."`.`url_redirects` set count=count+1 where `short`='".mysql_escape_string($short), $db);  
 $row = mysql_execute_update($query);

应该做。

I am assuming you followed the php version of his tutorial. If so look at the listing for serve.php under "Serving the Short URL". In the section round line 11 where it sets the 301 status you can log the redirect there with an update to the database. Something like

 $query = mysql_query("update `".$database."`.`url_redirects` set count=count+1 where `short`='".mysql_escape_string($short), $db);  
 $row = mysql_execute_update($query);

should do it.

烟若柳尘 2024-09-16 23:39:57

这里有一个迂回的替代方案——非脑损伤的方法怎么样?尝试在网站上放置 Google Analytics。您不仅可以获得点击报告,还可以跟踪网站的路径、进出、网络属性、用户位置等。这是一个简单的 JavaScript 包含,从开始到完成设置只需要 5 分钟。

我已经成为 PHP 开发人员很长时间了,我个人的理论是,有很多挑战需要解决,没有理由浪费时间在其他人愿意给你的解决方案上......

Here's a round-about alternative--How about a non-brain damage approach? Try putting Google Analytics on the site. You'll not only get a click report, but can also track paths through the site, ins vs outs, network properties, user locations, etc. It's a simple javascript include, and takes all of 5 minutes to setup start to finish.

I've been a PHP developer for a long time, and my personal theory is that there's a lot of challenges that need to be solved out there, no reason to waste time on solutions others are willing to give you...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文