Jump to content

counting clicks using onclick


n8w

Recommended Posts

I currently keep track of external click throughs on my site using a POST form that goes to a php script that looks up the id and then sends the user to the url and counts them as a click if they haven't already been to that link. (based on their ip and user-agent)

 

Is this the best way to approach this? I am sure there is a better way.

I am thinking it might be better to use the onclick event so seach engines can follow the links on my site

 

example

 

instead of using a form like this

<form action="go.php" method="post" name="frmMyForm8037" target="_blank">
<a href="JavaScript:document.frmMyForm8037.submit();"> <img src="../../images/illustrators/8037.jpg" alt="Matte Stephens" width="190" height="190" border="0" /></a><br />
<input type="hidden"  value="8037" name="user_id" />
<input type="hidden"  value="ae1c65bbc4e2eb5bcd269273bc80ff4c" name="token" />
</form>

 

use onclick like this

 

<a href="http://www.mattestephens.com" onclick="go.php?user_id=8037&token= ae1c65bbc4e2eb5bcd269273bc80ff4c"> <img src="../../images/illustrators/8037.jpg" alt="Matte Stephens" width="190" height="190" border="0" /></a>

 

How would you approach this with the following things in mind_

  • seach engines can follow my links
  • clean/simple
  • people can't cheat by clicking a billion times on one link to make it rank higher

 

 

 

 

 

Link to comment
Share on other sites

The GET method works fine for this approach.  The id in the URL is not sensitive data at all.  You don't even need an onclick.  Simply

 

<a href="/go.php?user_id=8037&token=ae1c65bbc4e2eb5bcd269273bc80ff4c">Text</a>

 

The onclick method would work better for search engines, but then you won't get links counted from anyone that has javascript disabled.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.