PHP 和 MySQL 中的短 URL 出站链接跟踪
我有一个基于 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您遵循了他的教程的 php 版本。如果是这样,请查看“服务短 URL”下的serve.php 列表。在第 11 行设置 301 状态的部分中,您可以在那里记录重定向以及对数据库的更新。类似的事情
应该做。
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
should do it.
这里有一个迂回的替代方案——非脑损伤的方法怎么样?尝试在网站上放置 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...