How to mark posts as visited

You can add a special custom field when a logged user visits any page.

A way to do this without editing the template file, is to use the filter the_content

add_filter('the_content', 'wpse_259159');

function wpse_259159($content){

    // check the user ID
    $current_user = wp_get_current_user();
    if ( 0 == $current_user->ID ) {
      // Not logged in.
    } else {
    // Logged in so we want to know if the custom field exists
    global $post;
    $visit_meta = get_post_meta($post->ID, 'users_visit_'.$current_user->ID.'_'.$post_ID, true);

        if($visit_meta){
            // the custom field exist
            update_post_meta($post->ID, 'users_visit_'.$current_user->ID.'_'.$post_ID, $visit_meta+1);
        }else{
            update_post_meta($post->ID, 'users_visit_'.$current_user->ID.'_'.$post_ID, '1'); 
        }

    }
    return $content; 
}

With this way, I don’t return any value or string in the content, and I write a custom field for each logged in user, depending on your needs (number of users and posts) this can be very bad for the database weight, so you can create an array of all user that visit the page. Adapt this to retrieve the value in the template if you need.

Hope it helps.