I'm looking for coding my own PHP URL shortener. I have already built a system that knows to take a long URL, turn it into a shortened one (something like domain.com/go/URLID
) and count the total click activity for it.
I want to add features like:
- Daily usage graph (like Google Analytics shows visitor graph in a month).
- Unique clicks count.
As I said, the code I made stores the total counts, but I'm not sure how to count unique clicks.
My approach for unique click counts is to use IP or cookies, but I'm not sure which one is more reliable (as cookies may expire and IP will count a full household as repeating clicks). How can I build this?
And the other part of click statistics by day: How can I do it? I was thinking about a very VERY long database table that stores every URL click, but I guess it will be too long, The queries will take time (and I have 300MB table size limit from my server provider).
I would like to get some help with the thing. I don't mind using external but free services (as long as I can use my own domain, of course).
Thanks!