Support » Plugin: Simple History » Monitoring frontend

  • Resolved premagraphic

    (@premagraphic)


    Hello, thanks for your work.
    Can Simple History monitoring the activity in frontend for logged users?
    for example, monitoring the pages viewed or the clicks in links?
    Do you have any suggestions?
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yes, It would be really good to have a shortcode that you could add to a page and then see it being tracked as an event in the reports.

    I have a recipe website and I really would like to see what users looked at what recipes.

    Hi @premagraphic
    I found the answer deeper into the Support forum a bit.
    Just add this to your function.php file:

    // Log page views by non-admin users
    add_action('wp_footer', function() {
        // Do not log admins
        if (current_user_can('edit_users')) {
            return;
        }
    
        // Log only page views
        if (is_page()) {
            apply_filters('simple_history_log_info', 'A user viewed the page "{page_title}"', [
                'page_title' => get_the_title()
            ]);
        }
    });
    
    • This reply was modified 3 months, 3 weeks ago by eoinlennon.
    Plugin Author Pär Thernström

    (@eskapism)

    Thanks @eoinlennon for finding and posting the snippet!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.