Comment on page
Tracking Virtual Page Change
This article covers using our virtualPage function to track virtual page change on your site. This implementation is only required for sites that use virtual page change.
If your site uses infinite scroll, serves up content dynamically, or pages change without the DOM refreshing, you will need to do some additional steps to capture those pageviews.
Anytime a visitor internally navigates to a new page via virtual page change, the
virtualPagefunction should be called. This function is specifically designed to register dynamic page change events with our tracker and can be attached to click/swipe events, or to a pixel that is used to trigger content changes. Best practice is to ensure that the
virtualPagefunction is called each and every time that your website serves up new changes to users dynamically.
You’ll need to set up logic to handle these lines of code:
sections: "New Section 1,New Section 2",
authors: "New Author",
title: "New Title"
If for example the dynamically loaded page has no section or author data, simply set that variable to an empty string to prevent our tracker from associating metadata from the previously viewed page of your site with the newly loaded page. For example:
virtualPageshould never be called when a user initially arrives on a page from an external source, and should only be called when a user navigates to subsequent pages without causing the DOM to be refreshed. The initial pageview event will be captured instead by our tracker, chartbeat.js.
Note: Most integrations will never need to use the
If your website has virtual pages you don't wish to track please call
pSUPERFLY.endTracking()when a user arrives to the non-tracked page via an internal page on your website. If the user then moves on to another dynamic page (i.e. a page that loads without a page refresh) and you want to track it, call
virtualPageagain for that new dynamic page.
The next article covers how to populate users' subscriber status data in your Chartbeat snippet so your team can filter on Guest, Registered, or Subscribed visitors to your website in our Real-time Dashboard.