jarv Posted June 6, 2013 Share Posted June 6, 2013 Hi, I have a link and would like to set a cookie on a link and when a user clicks that link it then shows an * Asterix next to that link to say that they have already been there, can anyone direct me to an online tutorial for this or guide me? thanks J Link to comment https://forums.phpfreaks.com/topic/278850-how-to-track-user-via-link-clicks/ Share on other sites More sharing options...
thebo0 Posted June 6, 2013 Share Posted June 6, 2013 You'll either have to use JavaScript or send users to the destination URL via your own URL. For example "/link.php?url=www.google.co.uk" - then you can set a cookie in "link.php" and forward them on. Link to comment https://forums.phpfreaks.com/topic/278850-how-to-track-user-via-link-clicks/#findComment-1434481 Share on other sites More sharing options...
jarv Posted June 6, 2013 Author Share Posted June 6, 2013 What? I have a php page with links, I just want to show a (*) next to the links that the user has clicked on Link to comment https://forums.phpfreaks.com/topic/278850-how-to-track-user-via-link-clicks/#findComment-1434491 Share on other sites More sharing options...
Irate Posted June 6, 2013 Share Posted June 6, 2013 Add this to your CSS. a:visited { color: rgb(130,30,100); } And then add this JavaScript to your page. window.onload = function() { var links = document.getElementsByTagName("a"); for(var i = 0, len = links.length; i < len; i++) { if(links[i].style.color == "rgb(130,30,100)") links[i].innerHTML += " (*)"; } }); Link to comment https://forums.phpfreaks.com/topic/278850-how-to-track-user-via-link-clicks/#findComment-1434492 Share on other sites More sharing options...
jarv Posted June 6, 2013 Author Share Posted June 6, 2013 Thank you! I was hoping for a way of doing his via cookies Link to comment https://forums.phpfreaks.com/topic/278850-how-to-track-user-via-link-clicks/#findComment-1434531 Share on other sites More sharing options...
Irate Posted June 6, 2013 Share Posted June 6, 2013 Well, theoretically, yes, you could set it with the same code I posted above, just that instead of directly applying it, you'd have to set a document.cookie value and then evaluate the document again, but I think that the method I provided is simple enough. Link to comment https://forums.phpfreaks.com/topic/278850-how-to-track-user-via-link-clicks/#findComment-1434569 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.