简体   繁体   English

跟踪用户 - 自定义PHP / MySQL网站分析

[英]Tracking Users - Custom PHP/MySQL Website Analytics

I run a local directory website (think yelp/yell.com etc) and need to provide analytical data to the businesses listed on the site. 我运行本地目录网站(想想yelp / yell.com等),需要向网站上列出的企业提供分析数据。

I need to track the following: 我需要跟踪以下内容:

1) Number of visitors to specific pages (ie: Jim's widgets was viewed 65 times) 1)特定页面的访问者数量(即:Jim的小部件被查看了65次)

2) Number of times a user clicks a link (ie: 25 users clicked to visit your website) 2)用户点击链接的次数(即:25个用户点击访问您的网站)

I am able to do this by simply adding one to the relevant number every time an action occurs. 我可以通过在每次动作发生时向相关数字添加一个来完成此操作。

What I would like to be able to do is split this into date ranges, for example, last 30 days, last 12 months, all time. 我希望能够做到的是将其分为日期范围,例如,过去30天,过去12个月,所有时间。

How do I store this data in the database? 如何将此数据存储在数据库中? I only need the theory, not the code! 我只需要理论,而不是代码! If someone can explain the best way to store this information, I would be extremely grateful. 如果有人能够解释存储这些信息的最佳方式,我将非常感激。

For example, do I use one table for dates, one for the pages/links and another for the user data (links clicked/pages visited)? 例如,我是将一个表用于日期,一个用于页面/链接,另一个用于用户数据(链接点击/访问过的页面)? The only solution I have so far is to add a new row to the DB every time one of these actions happens, which isn't going to scale very well. 到目前为止,我唯一的解决方案是每当其中一个动作发生时向DB添加一个新行,这不会很好地扩展。

Thanks to anyone that can help. 感谢任何可以提供帮助的人。

I would not reinvent the wheel and use an already available solutions such as Piwik . 我不会重新发明轮子并使用已有的解决方案,如Piwik It can actually read your normal weblogs to provide all the information you asked for. 它实际上可以读取您的正常网络日志,以提供您要求的所有信息。

If for some reason you still need a custom solution, I would not save the tracking data in ranges, but rather use exact time and url-data for each individual page call (what your normal weblog provides). 如果由于某种原因您仍然需要自定义解决方案,我不会将跟踪数据保存在范围内,而是为每个单独的页面调用使用准确的时间和URL数据(您的正常博客提供的内容)。 The cumulated data should be generated on-the-fly in your logic section, eg through a SQL-view: 累积数据应该在逻辑部分中即时生成,例如通过SQL视图:

SELECT count(url),url
FROM   calllog
WHERE  calldate > NOW()-30days

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

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