Woopra Docs

The Woopra Developer Hub

Welcome to the Woopra Developer Docs developer hub. You'll find comprehensive guides and documentation to help you start working with Woopra as quickly as possible.

Get Started      Documentation Reference


Tips for Tracking in Single Page Applications

The biggest issue with installing tracking code in Single Page Applications is that you cannot simply copy the tracking code and paste it into your page <head>. This is because the idea of an SPA is that the page head is not reloaded all the time, but rather just parts of the page are updated based on data-only (not full page html) requests are made in the background.

If you have developers and they are implementing custom event tracking, you shouldn't have a problem with this, as an SPA developer should be intimately familiar with this issue as it is core to the concept of SPA's.


The Snippet and the Config: in the <head>

You will probably still want to load the The Javascript Snippet in your page <head>, along with your tracker configuration (e.g.: woopra.config()). You will be unable to track all of your visitor's behavior if you simply put your tracking code (e.g.: woopra.track()) in the <head> area though because it will only run once at page load, and subsequent actions taken by the user in your web-app will not be automatically re-tracked.

Where to Track

What this means is that you will have to implement some level of custom tracking, even if you aren't creating custom events, you will still need to put your calls to woopra.track() into the event handler functions that are relevant. For instance, if you are a media content site, and you have a handler function that runs when a new article is loaded, THAT is where you want to put your call to woopra.track(), maybe even while you're at it, adding a custom event to the call:

woopra.track('article-view', {
    article_author: "Ralph Samuel",
    article_title: "How to Track Data in an SPA",
    article_topic: "Tracking Implementations"


Tips for Tracking in Single Page Applications