Troubleshooting issues with your Field Testing installation


In this article, we will go over some common issues you may encounter when adding the JavaScript code for PageVitals Field Testing, along with possible reasons and recommended solutions.

Field Testing verification

  1. Script not inserted correctly
  2. Script altered or removed
  3. Content Security Policy (CSP)
  4. Low sample rate
  5. Ad blockers

1. Script not inserted correctly

One of the most common reasons for the JavaScript code not working is that it hasn't been properly injected into the site's HTML.

Possible reasons

  • The script was added after the closing </head> tag, causing it not to load properly.
  • The script was added in the wrong file, such as a template file or a footer file.

Solution

Double-check the process for adding the JavaScript code to your website. Ensure that it is included correctly within the <head> section of the site's main HTML file, such as header.php or index.html. Refer to the Field testing installation guide for specific instructions.


2. Script altered or removed

If the JavaScript has been altered or removed from your site, it can cause the monitoring to fail.

Possible reasons

  • The script code was accidentally modified or deleted while editing other parts of the site.
  • An update to the site's theme or CMS replaced the file containing the script.

Solution

Double-check the JavaScript code in your site's source code to make sure it's present and matches the original code provided by PageVitals. If you find any discrepancies, correct them and re-add the original script.


3. Content Security Policy (CSP)

Content Security Policy (CSP) is a security feature that helps prevent cross-site scripting (XSS) and other code injection attacks by specifying which sources of content are allowed to be loaded by the browser.

Possible reasons

  • Your website's current CSP does not allow the script to be loaded or executed.
  • Your CSP does not allow the script to send data back to the PageVitals platforms.

Solution

Review and update your website's Content Security Policy to include cdn.pgvt.io in script-src and in.pgvt.io in connect-src. Here's an example of how to add the correct CSP headers to your website:

<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' cdn.pgvt.io; connect-src 'self' in.pgvt.io">

By updating your website's CSP, you'll ensure that the Javascript code can load, execute, and send data to us without being blocked by security measures.


4. Low sample rate

A low sample rate may cause the JavaScript code not to collect data for every user visiting your website. Setting the sample rate is done under Settings / Field Testing. If you have set the sample rate so low that it takes a very long time for the first data to be picked up, simply increase the sample rate until you get field data - and then adjust it again.


5. Ad blockers

Ad blockers and privacy extensions can sometimes block the JavaScript code from running or sending data.

Possible reasons

  • The PageVitals Field Testing script is flagged as tracking by ad blockers.
  • Certain privacy extensions prevent user data collection.

Solution

While it's difficult to bypass ad blockers and privacy extensions, you can monitor the impact of these blockers on your field data by comparing it with other metrics, such as server-side monitoring data or analytics data from different providers.

None of this helped?

Contact us