Single-page application support

Koko Analytics supports single-page applications where the page is not fully reloaded while navigating between pages. To make this work you need to manually call window.koko_analytics.trackPageview(path, post_id) for every navigation event.

Example: navigating to /about/ with post ID 50

window.koko_analytics.trackPageview('/about/', 50);Code language: JavaScript (javascript)

Example: navigating to an archive page

If the target page is not a singular post or page, you can pass in 0 as the post ID.

window.koko_analytics.trackPageview('/category/news/', 0);Code language: JavaScript (javascript)

Note that you don’t need this for traditional (multi-page application) WordPress sites. If you are unsure about your site, you very likely do not need this and Koko Analytics will work out of the box.

Was this article helpful? Yes / No