[resolved] [Plugin: WordPress.com Stats] Fix for Stats not recording page views (3 posts)

  1. panscendo
    Posted 7 years ago #

    After I upgraded and changed my page template, Stats was no longer recording any page hits. After some time lurking on the forums and trying different things I finally figured out what the problem was. Hopefully my fix may help someone else.

    In the Stats php file I noticed that the tracker is added by appending the code to the wp_footer() function called by the page templates. If the template doesn't use wp_footer() then the Stats tracker wont be added. So I checked my template to make sure that it was in fact calling that function. Nope, it wasn't - it was calling get_footer(). So I edited the Stats .php file and changed 'wp_footer()' to 'get_footer()'.

    Disclaimer: I did this a few days ago so details may be a bit fuzzy. Also, I basically have no idea what I was doing so use this fix at your own risk. Devs, anything to add?

  2. bshirley
    Posted 7 years ago #

    Good call.

    I've been sitting there for weeks saying "I know I have visitors, I have comments".

    I duplicated the line, figuring if I switch themes, the page will use one or the other, so cover my bases:

    stats/stats.php - toward the bottom:

    // Plant the tracking code in the footer
    add_action( 'wp_footer', 'stats_footer', 101 );
    add_action( 'get_footer', 'stats_footer', 101 );
  3. lusse
    Posted 6 years ago #

    thanx for the tip :) gonna see if it works :)

Topic Closed

This topic has been closed to new replies.

About this Topic