Skip to content
English
  • There are no suggestions because the search field is empty.

Integration with Quantum Metric

Learn how to integrate the Pisano Web Widget with Quantum Metric by using the onLoad callback. This integration retrieves the Quantum Metric replay URL and passes it to Pisano as a custom attribute during widget initialization.

What You Will Find Here

Prerequisites

Before implementing this integration, ensure that:

  • The Pisano Web Widget is installed on your website.
  • Quantum Metric is available in your environment.
  • You have your Pisano Widget ID.

Quantum Metric Integration

Use the following implementation to retrieve the Quantum Metric replay URL and pass it to Pisano before the widget is displayed.

(function (p, i, s, a, n, o) {
  p.PisanoObject = s;
  p[s] ||
    (p[s] = function () {
      (p[s].q = p[s].q || []).push(arguments);
    });
  p[s].l = +new Date();
  n = i.createElement(a);
  o = i.getElementsByTagName(a)[0];
  n.src = "https://web.pisano.co/scripts/widget/widget.js";
  o.parentNode.insertBefore(n, o);
})(window, document, "Pisano", "script");
 
Pisano("onLoad", function () {
  try {
    // Load Quantum Metric script asynchronously
    var qm = document.createElement("script");
    qm.async = true;
    qm.src = "https://cdn.quantummetric.com/qscripts/quantum-******.js";
 
    var scriptTag = document.getElementsByTagName("style")[0];
 
    // Check if Quantum Metric API is already loaded
    if (!window.QuantumMetricAPI) {
      scriptTag.parentNode.insertBefore(qm, scriptTag);
    }
 
    // Logic to capture Quantum Metric replay URL and boot Pisano
    var onStart = function () {
      var qmReplayUrl = QuantumMetricAPI.getReplay();
 
      Pisano("boot", "PSN-*****", {
        customAttributes: {
          qmReplayUrl: qmReplayUrl
        }
      });
    };
 
    if (!window.QuantumMetricAPI) {
      window.QuantumMetricOnload = function () {
        window.QuantumMetricAPI.addEventListener("start", onStart);
      };
    } else {
      window.QuantumMetricAPI.addEventListener("start", onStart);
    }
  } catch (e) {
    // Boot Pisano without Quantum Metric if an error occurs
    Pisano("boot", "PSN-*****");
  }
});

This implementation retrieves the current Quantum Metric replay URL and sends it to Pisano through the customAttributes object during widget initialization.

* Values marked with asterisks (*) should be replaced with your own Quantum Metric script and Pisano Widget ID before implementing the integration. 

How the Integration Works

The integration follows this sequence:

  1. The onLoad callback starts after the widget is initialized.
  2. The Quantum Metric script is loaded asynchronously if the Quantum Metric API is not already available.
  3. The integration waits for the Quantum Metric start event.
  4. The replay URL is retrieved by calling QuantumMetricAPI.getReplay().
  5. The replay URL is passed to Pisano as the qmReplayUrl custom attribute.
  6. The widget is initialized by calling Pisano("boot", ...).

Error Handling

The integration includes a fallback mechanism.

If the Quantum Metric script cannot be loaded or an error occurs while retrieving the replay URL, the widget is initialized by using the standard Pisano("boot", "PSN-bwxd53d") call. This ensures that the widget remains available even if the Quantum Metric integration cannot be completed.

Backward Compatibility

The Quantum Metric integration is optional.

If the integration is not implemented, the Pisano Web Widget continues to work by using the standard widget initialization method without any additional changes.

FAQs

Why is the replay URL passed to Pisano?

The replay URL is passed as the qmReplayUrl custom attribute so it can be associated with the feedback submitted through the widget.

What happens if the Quantum Metric API is already available?

The integration detects the existing API and reuses it instead of loading the Quantum Metric script again.

What happens if the Quantum Metric integration fails?

If an error occurs during the integration, the widget falls back to the standard initialization process and continues to load without the Quantum Metric replay URL.