Need a way to track realtime movements within site

I need a way to track logged in users and in realtime know if they are on a specific page. I need to gather the ids of visitors at a live event - so this would be those that have logged in, are of a specific user level, and are currently on a specific page. I'm guessing this is a custom development project, but if so, what would be the simplest approach to accomplishing this. Better yet, if there's a plugin that could take me half or all the way there.

  • Sumit Kumar

    Hello there, @stevew1000
    Hope you are having a good time :slight_smile:

    The thing you are asking for tracking users visited page, well honestly, I've never tried for this yet. However, before answering to you, I quickly searched for any available plugin for this and then I came out with the same result that our colleague, @Michael pointed. In addition, there's some more plugins of that kind, which I think you might have also gone through, before asking with us.

    Now, there is two perspective for what you are saying. The way you are saying to record pages visited in "user meta" is not that big deal, but then we need to create a dynamic dashboard that will be refreshed on real time and need to be more interactive. Similarly, we need to realize how to combine multiple users record to display in same dashboard. And there are many more features that lack in custom development like recording each session, time visited, ip tracking and many more.

    Having said that, it is wise to go with plugins that shows statistics as well as the pages visited per user and per session and this is what you needed, right! Wassup here gives that insight very interactively but if you don't want to use it then there is one more that fits your need: usertracker. It has got the exact description of its plugin which you mentioned in your comment, above. But I'm afraid, its outdated and you may consider to continue it from there :wink:

    Hope this was helpful. Let us know if we can be of any assistance, further.

    Regards, Sumit

  • stevew1000

    Sumit,

    What I am looking for is way simpler than what you're describing. Here's it in a nutshell:

    A user visits a certain page that has the code/plugin. The code/plugin creates/edits a usermeta key/value for that visitor: the key is "checkin". the value is the postID.

    That's all I'm looking for. No dashboard or any of that other stuff needed. If you can advise the best way to do that or have some code that can do that, it would be great help. Otherwise, I'll figure it out.

    Thanks for your help.

  • Sumit Kumar

    Hi again @stevew1000,
    Thanks for getting back, again :slight_smile:

    Not sure how much I can help you with this, but just trying if i can make it for you anyhow :slight_smile: Can you see the attachment and confirm, if this kinda record is what you need? What I'm doing is, recording each user's page/post visit with time_stamp. You can extract them from user ID in form of array, anytime. Here's the code:

    function store_pages_visit(){
    	if(is_user_logged_in()){        //only for logged-in users
    		if(is_page() || is_single()){      //only for pages or posts
    			$current_user = wp_get_current_user();
    			$checkins = get_user_meta($current_user->ID, 'checkin', true);
    			$checkins[time()] = get_the_ID();   //stores as per timestamp
    			update_user_meta( $current_user->ID, 'checkin', $checkins );
    			//echo &quot;<pre>Checkin for user {$current_user->user_login} <br>&quot;; print_r($checkins); echo '</pre>';
    		}
    	}
    }
    add_action('wp_footer', 'store_pages_visit');

    You can add this stuff in your theme's functions.php.

    Now, as I said, I'm not sure how deeply I could help you on this, and if I get you correct, then we can modify it to get the way we need to save the page/post IDs :slight_smile:

    Hope this was helpful.
    Please advice, how can we assist to answer your query here.

    Regards, Sumit

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.