• Resolved Saarfuchs

    (@saarfuchs)


    Hi folks,

    in my blog, I create some virtual pages from data from a custom database table. Therefore I use filters like rewrite_rules_array, query_vars and template_include. The created virtual page has no post_id or post metadata but of course an url.

    Now I noticed that google analytics is counting these virtual pages by their urls. But the jetpack statistic is not showing these pages.

    Is there a way to check if the stat counting script is placed on the virtual page? How do I place the counting script manually on these virtual pages?

    Thanks in advance for your help!

    Greetings from Germany
    Joerg

Viewing 1 replies (of 1 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I’m afraid that won’t be possible. Jetpack Stats rely on post IDs to store its stats. If a page doesn’t have a post ID, it can’t be tracked by Jetpack.

    Is there a way to check if the stat counting script is placed on the virtual page?

    The script is hooked into wp_footer(), and will consequently appear at the bottom of your source code, right before the closing </body> tag, when you’re logged out of your WordPress account. Here is how it looks on your site, for example:
    https://i.wpne.ws/jOyB

    As you can see, the script includes a post parameter that matches the current post ID. It’s set to 0 on the home page.

    How do I place the counting script manually on these virtual pages?

    If wp_footer() is added to the page, the stats tracking code will be added. However, since no post ID exists, the post ID is most likely set to 0, the default fallback:
    https://github.com/Automattic/jetpack/blob/4.6/modules/stats.php#L140-L165

    I hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Stats on virtual pages’ is closed to new replies.