Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Proposal: Tracking website activity #58

@dinever

Description

@dinever

It would be great if we can show some web analytics information on the dashboard. For example:

  • How many page views I had during the last week?
  • What are the top pages of my blog?
  • Where are the visitors from?

To implement this, we need two new endpoints. For, example:

  • /track/track.js
  • /track/track.gif

track.js is a simple JS script that request the 1 pixel GIF image from the backend server, with URL, page title and referrer(URL of the previous webpage) as parameters.

(function(){
    var d = document, i = new Image, e = encodeURIComponent;
    i.src = '/track/track.gif&url=' + e(d.location.href) + '&ref=' + e(d.referrer) + '&t=' + e(d.title);
    }
)()

track.gif is a 1 pixel GIF image, hard-coded in the backend server. When track.gif is requested, the server takes the parameters described above as well as the request header information, and insert an entry in the table page_views of the database:

CREATE TABLE "pageview" (
    "id" INTEGER NOT NULL PRIMARY KEY,
    "url" TEXT NOT NULL,
    "timestamp" DATETIME NOT NULL,
    "title" TEXT NOT NULL,
    "ip" VARCHAR(255) NOT NULL,
    "referrer" TEXT NOT NULL,
    "headers" TEXT NOT NULL,
    "params" TEXT NOT NULL
);
CREATE INDEX "pageview_timestamp" ON "pageview" ("timestamp");

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions