Ok, I think that makes sense. I just wasn't positive what you were going to use it for.
You could use session variables to store this information.
You could start a session, define the variable, then you would need to change how your links are displayed on the screen. They would need to be displayed in php so you could do something like this:
echo "<a href=\"link.php\" onClick=\"<?php sess_variable=\"yourtrackingcode\";?>\"<b>Click Here for Link </b></a>";
That way your session variable would be set when they click on the button.l
If you don't want to have to echo out the php <a href> information you could just do this:
Make your link like this: <a href ="yourlink.php?track_code=yourtrackingcode>Link</a>
Then use the $_REQUEST[track_code]; on the yorulink.php and asign its value to a session variable on yourlink.php page.