How to enable link hits?

Hello!

I am currently working on an open source script, a link directory one, and I was wondering if there is a chance I could register the link hit without making it internal…

Ex link href: hxxp://mydirectory.tld?goto=hxxp://link-url-here

thank you in advance!

no one?? :frowning:

please?

I am not sure what you are asking.

while trying to explain it better, I just realized the truth: “there is no spoon” :frowning:

that’s something I cannot accomplish.

As to what I wanted:
store in the db a number reflecting the number of times a link was clicked, and I wanted to do that without making the links’ href attribute internal, Ex:


 <a href="http://my-directory.com/send?destination=http://some-website.com/">some website.com</a>

but something like:


 <a href="http://some-website.com/">some website.com</a>

and whenever the link is clicked to be able to register the hit. But I realized that the only way I can do this is to use javascript, but that would not be an option because it will not reflect the accurate number of hits, because I cannot assume all visitors will have js enabled in their browser…

so I’m stuck :frowning:

If you are allowing links to be made, without checking them, nasty links could appear, which degrades your solution.

Yes I know, but that’s not gonna happen because I am a freak when it comes to validation the data that comes in or goes out of my website.

ty :slight_smile:

oh ok. yeah without javascript you are stuck it looks like.

Have you done any research into the amount of visitors you would have without js enabled? I can understand being wary for using javascript only solutions for core functionality such as navigation but for click throughs maybe build in a toggle to choose between the ‘less accurate’ JS link tracking or a more traditional tracking method and let the script owner decide.

Even stats from 2008 (http://www.w3schools.com/browsers/browsers_stats.asp) show that users with js turned off amounted to 5% and i’d assume this would be significantly lower due to the growing usage of js libraries and general JS UI enhancements over recent years

@romance;

I totally agree with you, but this script when finished is gonna be open source so anyone can download and use it so I’m not comfortable with releasing a script that will impose a decision that could easily be set as an option,

so these came to my mind while writing this:
#1: [hmm…] I won’t provide the hit counter at all, so all link would be external, pointing directly to their owners’ sources
#2: [better] I would provide the script with the following options:
- no link hit counter
- internal hit counter (like google’s search)
- javascript link counter
This way, I’ll be at peace because whatever the owner decides it’s his decision and not mine for him :slight_smile:

what do you think? would the #2 be the the way to do it?

I would use an ajax java-script request. The ajax request can pass the link url to your php count click script. You might have to use the javascript function to send the person to the next location after the ajax has been called.

i.e.
< a href=“whatever.com” onclick=“return false; gotLink(‘whatever.com’):”>whatever.com</a>

by saying “return false;” you tell the browser not to fallow the link, then in your javascript function you use the location = var; to send the person to the next page.

Does this make sense?