A new approach to documenting _php tutorials with PHP

Source: Internet
Author: User
If you use a good record analyzer, like analog or something like that, it's not too difficult to figure out where your site is coming from and which pages have been browsed.

But if you want to make the running report stop, you have to use a different route.

About six months ago, I was introducing Apache's record file into a SQL database and made a special query for him.

Unfortunately, this makes it necessary for me to manually crawl these records one by one, twist a little bit, and then output. I want something better-something that can be kept up to date, which gives me the information about which content is browsed, the statistics of the browser and the platform, and the trend over time.

The solution version of this article can make me very good to use for several years. I raise his importance when we build sourceforge through the SourceForge system, through all the records and tracks of this sourceforge.net site pipeline, Included on this site are the Web browser and every web browser on the 1200 project.

Basically, every record I'm going to do is add a column to the table on a database (in this example, a Web browser, but you can record a banner ad from the other URL to add a browser, click on the number, and click it separately). And so on

This is the table structure I'm using on SourceForge:

CREATE TABLE Activity_log (
Day integer DEFAULT 0 is not NULL,
Hour integer DEFAULT 0 not NULL,
group_id integer DEFAULT 0 not NULL,
Browser varchar (8) DEFAULT Other is not NULL,
ver float (Ten) DEFAULT 0.00 not NULL,
Platform varchar (8) DEFAULT Other is not NULL,
Time integer DEFAULT 0 not NULL,
Page text,
Type integer DEFAULT 0 not NULL

);

If you want to try to record multiple URLs, group_id can use this column. As long as each URL is assigned a different group_id, and it is passed to the URL address (shown below).

The type is unused in these examples, but you can use him to track different types of behavior, such as the number of ad points selected, the number of points that come from other URLs. Wait a minute.

Browser,ver,platform can be transferred from your browser to the website server step is to transfer the data to the table. It would be a perfect world if all that was in the box was useful through PHP and all the other different websites. Unfortunately, I have a large number of servers scattered throughout the country, and I have 24 hours a day to collect each of the server's web browsing information.

So I have to use a 1x1 pixel gif trick. I have a GIF on every server page that looks like this:



There are four components in this graph

Remote Web Server
Web browser (users who visit the site)
Central logging Server
Central database Server

So when users visit the site and get a Web page to use, the browser asks the server center to see a 1x1 GIF image. Server Center records that information makes the report easier.

Report

Just write some simple SQL to produce all the data.
Use Showresults () function to show that you can also use a graph (refer to prior article)

Now I can execute my stats report at any time.

Sample SQL to run reports
Page views by day

SELECT Day, COUNT (*)
From Activity_log
WHERE type=0 GROUP by day

Page views by Browser

SELECT Browser, COUNT (*)
From Activity_log
WHERE type=0 GROUP by browser

Page views by Browser Version

SELECT Browser, ver, COUNT (*)
From Activity_log
WHERE type=0 GROUP by browser, ver

Page views by Platform

SELECT platform, COUNT (*)
From Activity_log
WHERE type=0 GROUP by platform

Here. zip contains browser detection and database abstraction libraries.

http://www.bkjia.com/PHPjc/532081.html www.bkjia.com true http://www.bkjia.com/PHPjc/532081.html techarticle If you use a good record analyzer, like analog or something like that, then it's not too difficult to figure out where your site is coming from and which pages have been browsed. But ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.