Support » Plugin: ThreeWP Activity Monitor » Tracking when logged in users visit the site?

Viewing 5 replies - 1 through 5 (of 5 total)
  • +1, I have almost the same question, for an online workshop I want to know what pages are viewed by specific users.

    +1. We need Instructors to be able to track student visits, but not see the stats for every site on the network. I found that enabling the option to allow ‘Administrators’ to see others’ logins gave them access to all of the stats for all of the sites. This goes against our privacy practices, so we can’t enable it…

    I also agree that logins aren’t as useful a stat as visits are. An already logged in user doesn’t seem to add any stats when they visit a new site on the network.

    I recently co-authored a plugin called Stream to track what logged-in users are doing.

    Would love to know what you think, and how it could be better!

    Hi! Has anyone found a good solution for this? I am in almost exactly the same boat!

    I used a piece of code to generate a .csv file for every user and that contains the url, date/timestamp and the name.

    I included the following code(file) in the header of the site with

    if ( is_user_logged_in() ) {
        //do include code

    made a folder called ‘logs’ in the root of the site and protected that.

    global $current_user;
    $firstname = $current_user->user_firstname;
    $lastname = $current_user->user_lastname;
    $useremail = $current_user->user_email;
    $id = $current_user->ID;
    $permalink = $_SERVER['REQUEST_URI'];
    $date = date('Y-m-d H:i:s');
    function getDomainFromEmail($email)
    // Get the data after the @ sign
    $domain = substr(strrchr($email, "@"), 1);
    return $domain;
    // Example
    $domain = getDomainFromEmail($useremail);
    $data = "" . $id . ";" . $firstname . " " . $lastname . ";" . $permalink . ";" . $date . "\n";
    $file_name = "logs/".$firstname."-".$lastname."-".$id."-@".$domain.".csv";
    $max_lines = 250;              #maximum number of lines you want the file to have
    $new_line = $data;               #content of the new line to add to the file
    $file_lines = file($file_name);     #read the file's lines into an array
    #remove elements (lines) from the end of the
    #array until there's one less than $max_lines
    while(count($file_lines) >= $max_lines) {
        #remove the last line from the array
    #add the new line to the front of the array
    array_unshift($file_lines, $new_line);
    #write the lines to the file
    $fp = fopen($file_name, 'w');           #'w' to overwrite the file
    fwrite($fp, implode('', $file_lines));

    It isn’t the most efficient way and I dont know how the web server is going to act when u have a lot of logged in users at the same time, but it works for me

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Tracking when logged in users visit the site?’ is closed to new replies.