Using The Page View API
This article explains the usage of the page view API.
Overview
Gainsight PX tracks page views automatically including when installed in SPA applications. Page View API allows for programmatically tracking virtual web pages for dynamic content or in applications that do not use routing. By default the PX track page view using document.title and document.location, it can be overridden using the following API:
aptrinsic('pageView', [pageDetailsObj])
The object can contain the following fields (none are required):
Name | Type | Description |
---|---|---|
title | string | page title, this will allow to categories the page |
url | string | a full URL to track (if the protocol or domain will be missing the URL will be relative to the current document.location.href) |
path | string | path part of the URL, needs to start with a slash (\/) |
Examples:
aptrinsic("pageView", {"url" : "https://example.com/user"});
Lets say the original URL is https://examle.com/user/[userId], and you do not want to track the user id on every page view. This way only the user path is tracked, alternatively you can call Aptrinsic page view with:
aptrinsic("pageView", {"path" : "/user"});
This way you only overrides the path portion on the URL
Another example can be change the page title, lets say it is SPA and you want to identify dynamic content by title. You can change the title like:
aptrinsic("pageView", {"title" : "update user details", "path" : "/userDetails"});
This way if you had a popup with user details you can also track this action with title and a specific path. In this case only URL path and title will be overridden