Jump to content

Recording links clicked


tabs

Recommended Posts

I'm looking at using a session and includes to monitor the links clicked on and the order by a user when an intranet document is used.

 

I can write the data to a test file using fopen but I need to know how to gather the data ?

 

Any ideas? Is there something similar to the onClick command in javascript that will pass a string (in this case the link name clicked) onto a function and this then writes it to the text file?

 

thanks for any help

Link to comment
Share on other sites

well, no matter what you will need to use some sort of server side language here (i'm going to assume PHP)

 

for internal pages, just record $_SERVER['REQUEST_URI'] every time the page loads

 

for external pages, make the links go to an internal page that can then redirect like:

link.php?url=http://www.hostname.com/external/page.html

then in link.php record the value of $_GET['url']

 

is that what you are looking for? if so, this should be moved to the PHP forum

Link to comment
Share on other sites

You can do this all client side since it is local. Do something like this:

<script>
function writeLog(link)
{
   //write link to a file
}
</script>
<a href="page.htm" onClick="writeLog(this.href)">test</a>

 

I think Scripting.FileSystemObject is what you need to write the file.

Link to comment
Share on other sites

put this code in a file

<?php
  session_start();
  if(!is_array($_SESSION['pages']))
    $_SESSION['pages'] = array();
  array_unshift($_SESSION['pages'],$_SERVER['REQUEST_URI']);
?>

 

and include it at the top of every page. it will build an array with all the pages the person has visited. The 0 index will always be the current page, 1 is the last page, 2 the second to last page, etc. So, to print the last page, after you do the include of the above code just do:

<?php
  if($_SESSION['pages'][1])
    print $_SESSION['pages'][1];
?>

Link to comment
Share on other sites

You can do this all client side since it is local. Do something like this:

<script>
function writeLog(link)
{
   //write link to a file
}
</script>
<a href="page.htm" onClick="writeLog(this.href)">test</a>

 

I think Scripting.FileSystemObject is what you need to write the file.

 

Isn't FileSystemObject an ASP component? (probably displaying my beginner status here.)

Link to comment
Share on other sites

not sure the session is actually that useful here - to record ALL data you will need to log it on every page load. This would mean writing a snippet that is included in every page that opens a file (maybe a file per user so you don't get any problems with locks) and logs the data required on a new line.

 

Client side is pointless as you won't have access to the data...

 

If your requirement is a little less strict then perhaps you could collect data in a session array and dump it say every time the array hits 5 records - may help a little on performance but lets be honest its not going to make a massive difference.

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.