Open phiwut opened 8 years ago
That is a nice idea! Do you mean for links in posts/comments or just any link? It could break the design though. If done well it could work though! I might give it a shot.
@master412160 I thought to every tag. How are you planning to accomplish this without a DB?
@phippuuuu localstorage. I'll give it a shot. No promises. I still have much to learn.
Hi @master412160, Just to clarify, is the goal to show the number of times the current visitor has clicked each link, or is the goal to show the total number of times every visitor has clicked the link?
@zackbloom the most convenient and useful feature for the admin/webmaster would be to see the total clicks not for each user on their own to see their own click count. However this could be a setting down the line.
What do you think is the most convenient way?
@master412160 Unfortunately Local Storage is not shared between computers, so it wouldn't be possible to use that to show the total number of clicks. As @phippuuuu mentioned, I believe you would need a central database of some sort to support total click counts.
An interesting way of implementing this would be to use Google Analytics. You could interface with the Google Analytics API to fetch the click counts, without having to keep track of them yourself. To do that though you need to have an API running on a server which can authenticate into the user's Google Analytics, and I think that might be beyond the scope of what you're looking to build.
@zackbloom @master412160 Would't it be possible to add a specific id to each tag with the number of clicks? Example:
<a href="http://www.eager.io">Test</a>
Becomes (5 clicks):
<a id="linkCounter5" href="http://www.eager.io">Test</a>
@phippuuuu You could do something similar with data attributes, but you'd need some other code to inject the appropriate counts into the html: https://jsfiddle.net/L9nxrdxx/
@zackbloom well I'll do it like that then.
@zackbloom @master412160 But how do you store the injected values on the Server? When you reload the Site, the stored values of the Server gets displayed, and not the before injected one...
It would be awsome if it would be possible to add a link counter (as seen on discourse). I don't know how to accomplish it because you cant use a database or something to store the amount of clicks...
here is a sample image: