Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Re: Counting click-throughs

by barrd (Canon)
on Nov 12, 2003 at 14:43 UTC ( [id://306534] : note . print w/replies, xml ) Need Help??

in reply to Counting click-throughs

Hiya Petras,
Thought I'd carry on a little from where Brer Aristotle left off. I've done many types of this over the years and would like to give a wee bit of advice. I started out by using flatfiles and the exact same technique as above to keep a count (the link went through a CGI opened the appropriate text file and then auto increment the number). However this gets messy pretty quickly and is hard to maintain.

Step in relational Db. I use MySQL but any other SQL Db would suffice. the reason I do this is to allow better control via a backend admin script to control all the elements of the promotion. Below is a basic typical setup I might have for an SQL table containing the fields;

  • UID (Unique ID)
  • Name of promotion (or in your case charity)
  • Clicks (number of hits)
  • Image (usually just a name or path)
  • URL link
  • Header text - optional (HTML)
  • Footer text - optional (HTML)
  • Created (date promotion started)
  • LastMod (date link was last clicked in this case)
  • Active ("Yes" or "No")

This means that your front end (HTML) page interacts directly with your back end admin script (via the Db) meaning that if you are capable of doing this (dynamic page building) not have to edit any hard coded HTML. I gave that up a "long time ago"... ;)

Anyway hopefully that might have given you an insight to a more proactive way of handling this situation. If you have any other questions either reply to this post or /msg barrd in the ChatterBox.

Best of luck...