Split TimeOnSite string into FocusedTime and SpentTime | XM Community
Solved

Split TimeOnSite string into FocusedTime and SpentTime

  • 26 October 2023
  • 4 replies
  • 48 views

I found on the support pages that the TimeOnSite field is reporting Spent time and Focused time separated by a pipe (|). I have tried many attempts to split this in the survey flow embedded data block, but nothing seems to work. ChatGPT and Bard also suggested to use Java Script in a text question or a calculated field in the survey flow, but those do not seem to be available options on the Qualtrics Employee platform.

 

Has anyone had any luck with trying to separate TimeOnSite into two fields? We would like to use this field in dashboards to report on site intercept stats.

Support Page

 

icon

Best answer by NZungia 1 December 2023, 22:43

View original

4 replies

Badge

Hi @LaurenR -- Did you end up finding a solution? I’m currently trying to solve the same problem and will report back with any updates. 

Hi @NZungia , I have not found a solution as of yet. I have reported this to our Qualtrics Enterprise Support team and they are currently looking into it as well. I’ll report back once I get an update!

Badge

Hi @LaurenR -- I’m unsure if this will work for your use case but I did manage to find a solution. Here’s my process

 

 

  1. Add in an appropriately named embedded data field to the intercept(s) the Survey is attached to.

  2. Set the value of the above embedded data field to "Time Spent on Site."

  3. Add an embedded data field to the Survey Flow whose name matches exactly that of the embedded data field in the intercept(s). (I.E. , if the Intercept EDF is called "SiteTime", the EDG in the survey must also be SiteTime)

  4. Add two EDFs in the survey flow beneath SiteTime and call them "TimeSpent" and "TimeFocus".

  5. Add Javascript to the first question the respondent sees (it is best if this is a forced response question).

  6. In the Javascript dialogue, replace the default script with the script below:

    1. Qualtrics.SurveyEngine.addOnload(function(){
      //Place your JavaScript here to run when the page loads
      //Javascript for splitting Time Spent/Focus on Sitevar
      str = "${e://Field/SiteTime}";
      var res = str.split("|");
      Qualtrics.SurveyEngine.setEmbeddedData('TimeSpent', res[0]);
      Qualtrics.SurveyEngine.setEmbeddedData('TimeFocus', res[1]);
      });

      Qualtrics.SurveyEngine.addOnReady(function(){
      /*Place your JavaScript here to run when the page is fully displayed*/
      });

      Qualtrics.SurveyEngine.addOnUnload(function(){
      /*Place your JavaScript here to run when the page is unloaded*/
      });

  7. Publish your survey.

  8. Test and verify that the fields are populating as intended. 

 

That worked beautifully! Thanks for the help, @NZungia.

Leave a Reply