Visitors stat counter and View Hit Counter for each list

How to add unique stat viewers and view hit counter for each listing and all website visitors can see it. It can be good for vendors in dashboard and visitors.

Currently there’s no such feature in the HivePress core and we avoid adding a simple counter that counts every page refresh, but you can try using Statistics - it counts unique visitors and views per listing, there may be a simple code snippet to show this count on the front-end page (currently it shows the stats to vendors only).

I’ve find this snippet from Post View Counter Without Plugins | paljordawa

How to use it for Hivepress listings page and I want only vendors can see their personal stats as private in their listing page and it’s hidden for other users and other vendors

function getPostViews($postID){
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 View";
    }
    return $count.' Views';
}
function setPostViews($postID) {
    $count_key = 'post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
 
// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); 


Sorry, there’s no simple snippet for implementing this, it requires customizations (for integrating into the HivePress templates, showing it to vendors only, and making it secure - the snippet you posted adds a view on every request so any script kiddy can easily set 1 billion views for their listing). You can also check the Statistics extension, it integrates HivePress with Google Analytics to show vendors page views and visitors of their listings for recent 30 days.

Where is “Statistics” and how can I download or enable this feature?

Statistics is an extension found on the hivepress.io main website, for $29. After purchase you follow the docs & video, and it runs analytics. It will tell the vendor how many views daily, weekly, monthly, total for past 30 days in a graph chart. You can also restrict this to vendors with certain packages with a code snippet. Let me know if you have any questions or need help with the set up.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.