• Resolved margmacd

    (@margmacd)


    Hello

    I am looking for a hits counters plugin that has functionality to record a cumulative count of the number of user visits to a site, irrespective of page or whether the user has logged in, and display this general count on site pages. Can you please advise if Independent Analytics can offer this functionality?

    Many thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ben Sibley

    (@bensibley)

    Hi there,

    Thanks for getting in touch about this.

    The view counter in Independent Analytics is page-specific, so it doesn’t show the overall stats for the whole site. However, we do have a developer API with a couple of simple PHP functions that can be used to get stats for the whole site.

    Thread Starter margmacd

    (@margmacd)

    @bensibley Many thanks for this kind response. Would it be possible to get some guidance on the code required to achieve the outcome I am looking for, which includes the site hits total appearing at the top or bottom of individual pages? Also, would it be possible to start the count from a chosen, figure? The site hits counter plugin I had used previously is not compliant with more recent PHP versions, and therefore, I am not longer able to use it. I have a very full schedule, so it really is a case of me dipping into my WordPress site to add enhancements, only when time allows.

    Plugin Author Ben Sibley

    (@bensibley)

    This PHP would output the site’s total views recorded since January 1st, 2025:

    $analytics = iawp_analytics(new DateTime('2025-01-01'), new DateTime());
    echo $analytics->views;

    It could be modified to output visitors or sessions instead.

    If you want to manually adjust the value, here’s how you could add 2,000 more views to the total:

    $analytics = iawp_analytics(new DateTime('2025-01-01'), new DateTime());
    echo $analytics->views + 2000;

    I would recommend using the WPCode plugin and adding this to a PHP code snippet set to run on the front-end. You can then get a shortcode for this code snippet, and the shortcode can then be added anywhere you want on your site.

    Thread Starter margmacd

    (@margmacd)

    @bensibley Thanks for providing some code. From previous counts, I estimate that the current hits total exceeds 12,000, so it would be good not to have to revert back to zero. Thanks also for suggesting the WPCode plugin. From grappling with some of the detail in your last message, it looks like I need to get to grips with the ‘PHP code snipper’ lingo, but from a brief look at the link you provide, this should be an integral part of learning about how this plugin works. I will try to find some time for making best use of this plugin to address my current site issue.

    Plugin Author Ben Sibley

    (@bensibley)

    Okay sounds good! Feel free to post here if you get stuck.

    Thread Starter margmacd

    (@margmacd)

    Many thanks, @bensibley!

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