QM logic not working on the survey | XM Community
Question

QM logic not working on the survey

  • 26 March 2024
  • 1 reply
  • 30 views

Badge +1

Hi All,

We have a survey that is currently being triggered using JavaScript to manually load our survey instead of the usual page load method. Additionally, we've integrated a QM script which provides session links, session cookies, and user cookies. However, we've encountered an issue where we're not receiving any values for the QMREPLAY.

I think it’s the way we are capturing QMREPLAY using the Javascript.

Here is the JS

 

Qualtrics.SurveyEngine.addOnload(function() {
/* Set QM Cookies that were passed via the Qualtrics Intercept */
 var session = Qualtrics.SurveyEngine.getJSEmbeddedData('QMSESSION');
 var user = Qualtrics.SurveyEngine.getJSEmbeddedData('QMUSER');
 document.cookie = "QuantumMetricSessionID=" + session;
 document.cookie = "QuantumMetricUserID=" + user;
 /* Load the QM tag */
 var qtm = document.createElement('script');
 qtm.type = 'text/javascript';
 qtm.async = 1;
 qtm.src = 'https://cdn.quantummetric.com/qscripts/quantum-aa.js';
 var d = document.getElementsByTagName('script')[0];
 !window.QuantumMetricAPI && d.parentNode.insertBefore(qtm, d);
 /* Wait for QM to Load */
 function onStart() {
  /* QM Finished Loading Set QM Replay Link in Qualtrics */
  var qmReplay = window.QuantumMetricAPI.getReplay();
  Qualtrics.SurveyEngine.setJSEmbeddedData("QMREPLAY", qmReplay);
 }
 if (!window.QuantumMetricAPI) {
  window.QuantumMetricOnload = function() {
   window.QuantumMetricAPI.addEventListener('start', onStart);
  };
 } else {
  window.QuantumMetricAPI.addEventListener('start', onStart);
 }
});
Qualtrics.SurveyEngine.addOnReady(function() {});
Qualtrics.SurveyEngine.addOnUnload(function() {});

If someone has any insights on how to fix this, would be greatly appreciated.


1 reply

Badge

@Niharikasingh I’m running into the same issue. I recently switched to the Simple Layout after reading in the JavaScript Question API documentation that a “query can still be imported by survey designers manually by adding a <script> tag in your survey’s header.

I added the following to the Header after following this post: Simple Layout - No JQuery? | XM Community (qualtrics.com)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
This allowed me to make some adjustments using JS to the Simple Layout.

However, the Quantum Metric JS is not working. Hoping to get some guidance too.

Leave a Reply