Skip to main content
Loading...
Skip to article
  • Qualtrics Platform
    Qualtrics Platform
  • Customer Journey Optimizer
    Customer Journey Optimizer
  • XM Discover
    XM Discover
  • Qualtrics Social Connect
    Qualtrics Social Connect

Single Page Application


Was this helpful?


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The feedback you submit here is used only to help improve this page.

That’s great! Thank you for your feedback!

Thank you for your feedback!


About Single Page Applications

Single Page Applications (SPA) are a special type of web app. An SPA will load a single page when you enter a website and, from that point on, load all subsequent content in that same page as you navigate. This will appear to work like a normal website, but when switching between “pages,” the page doesn’t actually reload.

By default, deployment code runs as soon as a web page loads. However, because SPAs don’t refresh when navigating between pages, deployment code will not re-evaluate as you navigate between pages. By using the techniques outlined below, you can enable the deployment code to function on your SPA site seamlessly.

Qtip: Some of these techniques use the Website Feedback JavaScript API. For detailed documentation on the JavaScript API for Qualtrics Website Insights, see this page.
Attention: The following documentation requires programming knowledge to implement. We recommend passing this information to the team that will be implementing your deployment code. Our support team does not offer assistance or consultation on custom coding. You can always try asking our community of dedicated users instead. If you’d like to know more about our custom coding services you can commission, please contact your Qualtrics Account Executive.
Qtip: Javascript is not included in all Qualtrics licenses. Please reach out to your Qualtrics Account Executive if you’re interested in getting access.


Auto Re-evaluating Intercept Logic Upon URL Change

If your Single Page Application depends on client-side routing for user navigation, you can force re-evaluation of intercepts upon subsequent URL changes by enabling the Re-evaluate intercept logic when the URL changes setting. Checking this setting will allow for intercept logic evaluation in addition to the evaluation that occurs upon the initial page load.

To enable auto re-evaluation of the intercept logic, follow the steps below:

  1. Go to Intercepts.
    intercept settings page
  2. Go to Intercept settings.
  3. Make sure that Re-evaluate intercept logic when the URL changes is checked under the Single-page App (SPA) Support section.
    single page application enabled
  4. Click Apply changes.
Qtip: If you’d like to test this behavior, you must use the project-level bookmarklet. You cannot use a specific intercept’s bookmarklet to test this behavior.


Re-evaluating Intercept Logic and Track Activity Upon URL Change

In the previous section, we showed how to support single-page applications for all intercepts in a project. However, if you want to support this behavior for all intercepts in a project and Digital Experience Analysis, you need to adjust a setting at the project-level instead.

Qtip: If you enable the setting in Manage project, the setting will automatically be applied in Intercept settings.

adding single page application from the manage projects tab

  1. Go to Manage project.
  2. Make sure that Re-evaluate intercept logic and/or track activity whenever the URL changes is checked under the Single-page App (SPA) Support section.
  3. Click Apply changes.

Attention: If you decide to use this SPA setting in conjunction with the intercept-level option to Display with custom Javascript code (manually), then you will still need to call the

QSI.API.run();

method in order to get the intercept to display on each SPA page.



Implementing Manually with JavaScript API

Qtip: For detailed documentation on the JavaScript API for Qualtrics Website feedback, see this page.

This method outlines how to switch your deployment code to run manually.  This means that the deployment code won’t run or evaluate the associated logic until the appropriate JavaScript API request is initiated.

To implement manually

  1. Go to Intercepts.
    intercept settings page
  2. Go to Intercept settings.
  3. Under the Intercept loading options heading, select Manually Load Project.
    intercept loading option selected
  4. Click Apply changes.
  5. If desired, return to one of your intercepts, and set logic to your entire intercept or individual action sets.
    intercept editor open and areas where you add logic are highlighted
  6. Place the deployment code into your website, preferably in a global header or footer so that it loads on all pages.
  7. Add the appropriate JavaScript API requests based on how many times you want your website to reference the Intercept. See section below for these requests.


JavaScript API Requests

Qtip: For detailed documentation on the JavaScript API for Qualtrics Website feedback, see this page.

If you want Qualtrics to evaluate your project in a single instance, use these two requests:

  1. This request loads the deployment code for any Intercepts and Creatives on the page. The “load” API is the same as reloading a page that has code on it.
    QSI.API.load();
    Qtip: If you have Manually Load Project enabled in your project settings, you will not need to call this API to load the deployment code upon initial page load. It will only be required to force loading to account for state changes on the page that occur without reload.
  2. This starts the deployment code evaluation and will make any Creative appear if it passes the display conditions.
    QSI.API.run();

If you want Qualtrics to evaluate your project code more than once on the same page, repeat the following three steps each time:

  1. This request removes the deployment code for any Intercepts or Creatives present on the page.
    QSI.API.unload();
  2. This loads the deployment code for any Intercepts or Creatives on the page. This is the same as reloading the page.
    QSI.API.load();
  3. This starts the deployment code evaluation and will make any Creative appear if it passes the display conditions.
    QSI.API.run();


FAQs

There are numerous potential causes as to why an intercept may not be appearing once it has been implemented. These causes may stem from the setup of the intercept itself or the implementation of the code.
  • Logic: intercept targeting logic and action set logic are the conditions that must be met in order for an intercept to be displayed to a visitor. Checking this logic will be helpful in discovering why the Intercept is not displaying on a page.
  • Logic sets that use “Contains”: A common cause of logic error is the use of the “Contains” vs. “Is.” To say a condition “Contains” means that the parameter you are basing the logic off (i.e., Current URL) will have the specified value present in addition to more information. For example, if I had logic that read as Current URL contains ‘qualtrics’, this would cause the intercept to display on any URL that has the word qualtrics present. The other option you have is using Current URL is [URL]. This condition depends on the visited URL being an exact match. Any differences or additional characters will prevent the intercept logic from passing.
  • Intercept Revisions: When making edits to intercepts, changes are not made live until the intercept is published. When publishing an Intercept, a version of the intercept, or a “revision,” is saved. Reviewing the revisions that have been made is very useful for identifying any changes that may have suddenly prevented the intercept from appearing.
  • Debug Window: The debug window is an invaluable tool for testing why an intercept is not displaying on a particular page.

    For intercepts whose deployment code was implemented before March 2019, to enable the debug window, append a query string to any given URL called Q_DEBUG. This must be prefixed with a ? or a & like the following examples: https://www.qualtrics.com?Q_DEBUG, https://www.qualtrics.com/blog?item=value&Q_DEBUG.

    For intercepts whose deployment code was implemented after March 2019, run the following JavaScript snippet in the Console of your web page:
    
     QSI.API.unload();
     QSI.isDebug = true;
     QSI.API.load();
     QSI.API.run();  
    The debug window breaks down all conditions required for intercepts running on the URL to appear. If you find that an intercept is not appearing, locate it in the debug window and identify any red failed warnings.
    Qtip: The Website Insights debugger does not function if the code has been implemented using a tag manager. Also, if the URL already has a query string with a ?, then the debugger will require a & instead.
  • Network Request: Most browsers possess a developer tools menu that allows a user to see a site’s source code, resources, cookies, and network calls. Website Insights possesses a distinct presence in the Network section of these tools. To check for these scripts running, open the developer tools and navigate to the Network section. Once here, reload the webpage and the menu should begin to populate with all network requests being made by the website. To identify Website Insights code, look for calls that begin with ?Q_ZID or ?Q_SID. This is the code itself running checks on the display logic. If you cannot find anything matching this format, then there is an issue with the implementation of your project code. You can refer to our support page on implementation for advice on where is best to place the code.
  • Content Security Policy Issues: If you receive a console log that violates a Content Security Policy, there is most likely a restriction on your website that is blocking our intercepts from deploying. We recommend reaching out to your web-development team to resolve. To ensure your intercepts work, we generally recommend allowlisting the following items in your Content Security Policy headers:
    • connect-src https://*.qualtrics.com
    • frame-src https://*.qualtrics.com
    • img-src https://siteintercept.qualtrics.com
    • script-src https://*.qualtrics.com
There is a tool called a bookmarklet that allows you to test any intercept without having to activate it.