I have been having a hard time finding a script to track my newsletter members clicks, I know this should be an easy 10 line code. and I think I saw this on an open source forum once but now can't find it. I want to pass links like: http://mysite.com/?test@mail.com?file.zip (this is the same as http://mysite.com/file.zip) I want to track the email address + the files name when clicked to a flat file .txt or .html any thoughts? Thanks, Mike
why not send it in a form using a POST variable to the page? So something like <form id = 'foo' name='foo' action = 'filedownload.asp' method = 'post'> <input type = 'hidden' name = 'userEmailFromDatabase' value= 'test@email.com'> <input type = 'hidden' name = 'filename' value = 'file.zip'> <input type = 'hidden' name = 'subchk' value = '1'> <input type = 'submit' name = 'submit' value = 'Download File'> </form> PHP: then your filedownload.asp would look something like if ($_POST['subchk'] == '1' && $_POST['filename'] > '' && $_POST['userEmailFromDatabase'] > '' ) { $track = callTheFunctionForTracking($_POST['userEmailFromDatabase'], $_POST['filename']); // call a function which updates the database with an email to filename link // then set the function to return true on success so you know you're tracking and then start the file download if($track){ echo '<a href = './files/file.zip'> click here to download the file </a>' } else { echo'error message goes here'; } PHP: Not saying this code here is the best or will work out of the box, (didnt test) but might give you an idea?
Using hidden fields is a great way to do it. But if it is just a link and not a form, you could use an onclick function in the url and do some ajax call.
Thanks firemarsh, forms is a really good idea, but my auto-responder has trouble with forms... but I may try it for something else. Thanks dweebsonduty, how would the ajax call look? I really don't know any ajax