Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Tracking website activity #58

Open
dinever opened this issue May 19, 2016 · 0 comments
Open

Proposal: Tracking website activity #58

dinever opened this issue May 19, 2016 · 0 comments

Comments

@dinever
Copy link
Collaborator

dinever commented May 19, 2016

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");
@dinever dinever mentioned this issue May 20, 2016
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant