如何管理页面浏览量数据库

发布于 2024-08-12 14:30:13 字数 279 浏览 8 评论 0原文

我有兴趣跟踪我的用户在我的网站上的页面浏览量。由于流量增长得非常快,我担心机器人等,而且我也希望能够实时使用跟踪数据来改变用户体验(因此,虽然我确实使用谷歌分析,但它不能用于此目的) 。

存储我的信息最有效的方式是什么?这是我当前的理论,请批评和/或提供更多想法:)

策略:收集 ip、页面 url、浏览器/版本、时间戳、加载时来自客户端的引用并将一行插入 MySQL。根据时间或性能确定某个时间间隔来“归档”表并删除行或通过 cron 创建新行。

这稳定吗?

I am interested in tracking my users' pageviews on my site. Being that traffic is expanding very quickly, I am worried about robots, etc, and I also want to be able to use tracked data live to alter the user experience (so, while I do use Google analytics, it does not serve this purpose).

What is the most efficient way to store my information? Here is my current theory, please critique and/or offer more ideas:)

Strategy: Gather ip, page url, browser/version, timestamp, referrals from client on load and insert a row into MySQL. Determine some interval based on time or performance to "archive" the table and either delete rows, or create a new one via cron.

Is this stable?

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

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

发布评论

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

评论(2

初与友歌 2024-08-19 14:30:13

我不完全确定,但是用户表(也许通过 cookie 或会话分配用户 ID)、页面表(这可能实用,也可能不实用,具体取决于它们的生成方式)怎么样?以及一个跟踪表来显示每个用户 ID 查看哪些页面(通过一些唯一的页面 ID 标识符)?

Pages:
page_id | page
01      | homepage
02      | site map
03      | about us

users
user_id  | user_ip_or_cookie_identifier
01       | 127.0.0.1
02       | 192.168.0.2

tracking
user_id  | page_id
01       | 01
01       | 03
02       | 01
01       | 02

(等等...)

然后使用简单的 MySQL(或您正在使用的任何数据库)查询来检索哪个用户查看了哪些页面。

主要的弱点是用户将在工作/家庭中拥有不同的标识符(除非您登录),并且每个 IP 地址都有多个用户,并且可能每个 cookie/会话(取决于用户对共享其工作站的开放程度) /件)。

I'm not entirely sure, but how about a table of users (perhaps assign a user-id, via cookie or session), a table of your pages (this may or not be practical, depending on how they're generated), and a tracking table to show which pages (via some unique page-id identifier) each user-id looks at?

Pages:
page_id | page
01      | homepage
02      | site map
03      | about us

users
user_id  | user_ip_or_cookie_identifier
01       | 127.0.0.1
02       | 192.168.0.2

tracking
user_id  | page_id
01       | 01
01       | 03
02       | 01
01       | 02

(etc...)

Then use a simply MySQL (or whatever DB you're using) query to retrieve which pages were viewed by which user.

The primary weaknesses are that users will have different identifiers from work/home (unless you log them in), and multiple users at each ip-address and, potentially, each cookie/session (depending on how open the users are with sharing their workstations/pcs).

污味仙女 2024-08-19 14:30:13

听起来很有道理。如果您希望插入速度尽可能快,则应该将该表设置为 MYIASM 并且不包含任何索引。

Sounds reasonable. You should make that table MYIASM and not have any indexes if you want inserts to be fast as possible.

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