Track Google “Web Stories” Using WP Statistics

If you’re using the Google Web Stories plugin along with WP Statistics on your WordPress website, you might have noticed an important issue: Visits to your Web Stories are not recorded by WP Statistics.

This happens because the Web Stories plugin enforces strict AMP compliance. AMP validation explicitly forbids external JavaScript files or any third-party scripts that can affect page speed and performance. WP Statistics relies on JavaScript tracking scripts, so it won’t track visits on AMP-compatible Web Stories pages by default.

Thankfully, there’s a simple solution to accurately track visitors to your Web Stories. You can quickly resolve this by adding a simple snippet to your active WordPress theme’s functions.php file:

function wps_web_stories_story_head()
{
    if (function_exists('WP_Statistics')) {
        \WP_STATISTICS\Hits::record();
    }
}

add_action('web_stories_story_head', 'wps_web_stories_story_head');

That’s it! Now you have accurate visitor tracking for your Google Web Stories pages without affecting AMP validation.

Let’s get started
Take your business to next level

Become part of our growing family of +600,000 users and get the tools you need to make smart choices for your website. Simple, powerful insights are just a click away.