data-track-pageΒΆ

To automatically track a pageview whenever certain HTML is visible on the page, you can use the data-track-page attribute. This is especially handy when working with single page applications.

<body data-track-page='{}'>
..
</body>

The code above shows the simplest way of tracking a page. This way you do not add any meta data. It is also possible to add meta data.

<body data-track-page='{
    "pageLanguage": "en"
}'>
..
</body>

The example above shows how to add the pageLanguage to the pageview.

If you want to decide yourself when the pageview needs to be tracked. You can use the pageview event in the Javascript API to have full control.