Triggering Virtual Pageviews

This function is needed for legacy deployments only! Changes to the URL via History.pushState() are now automatically picked up by Inspectlet so the below is unnecessary.

 

If your site is a single page application or otherwise uses HTML5's History API (e.g. pushState) or uses hash-bangs to change application state, you can trigger a virtual pageview, which tells Inspectlet to create a new page record.

Please note: Virtual Pageviews should not be confused with changing the Page URL. For example, if you're on /foo and change the page URL to /bar, the end result will be that Inspectlet will have a session with one pageview: /bar. If you're on /foo and perform a virtual pageview, Inspectlet will have a session with two pageviews: /foo,/bar. Changing the page URL lets you modify what Inspectlet is seeing for the current page, while the Virtual Pageview API triggers an entirely new pageview within Inspectlet.

Trigger a virtualPage like this:

__insp.push(["virtualPage"]);

In single page apps made with frameworks like AngularJS, Ember, Backbone, etc, you only need to add the virtualPage call once in your routing function that faciliates page changes.

Simulating a URL

When a virtual pageview is triggered, Inspectlet will automatically pick up on the new URL from window.location.href, but if you'd like Inspectlet to use an artificial URL (exactly the same as calling the pageUrl method) instead, you can send in a URL like so:

__insp.push(["virtualPage", {url: "www.example.com/test/location.html"}]);

Please note that most of the time you don't need to simulate a URL, plain old virtualPage works just fine.