Page path


Change page path

You can change the path of the page, as seen in the Field Testing dashboard. This can be useful if you want to group different URLs into a single URL, or if you have A/B test variants that you want to be able to distinguish from one another.

In this example, the page path is set to "/products/{product-name}", thereby grouping all product pages into one:

(window.$pagevitals ||= []).push({ path: "/products/{product-name}" });

Include a querystring parameter in the path

By default, PageVitals only includes the path (location.pathname) in the UI. However there can be situations where you want to include one or more querystring parameters in the PageVitals UI. That can be done like this:

const myParam = "myParam";
const searchParams = new URLSearchParams(location.search);
if (searchParams.has(myParam)) {
(window.$pagevitals ||= []).push({
path: location.pathname + "?" + myParam + "=" + encodeURIComponent(searchParams.get(myParam))
});
}

Including all querystring parameters in the path

If you want to include all querystring parameters in the path, you can add this script:

(window.$pagevitals ||= []).push({ path: location.pathname + location.search});

Automatic grouping of IDs and UUIDs

If your page path contains an identifier such as a numeric ID or a UUID, PageVitals will automatically replace those identifiers with {id} so they are automatically grouped. This feature can be disabled by making this call:

(window.$pagevitals ||= []).push({ keepGUIDs: true });