Mandating clicking on the Embedded Link in the Survey + timestamp for the click | XM Community
Skip to main content

Hi
I have embedded a link in my survey that I want all respondents to click on. I need help with the Java Script code for three functions, listed below. I would really appreciate any help with this! Thank you so much.

  1. I want to prevent the Next Button from showing until the participant has clicked on the embedded link. This is just a way to ensure that the participant clicks on the link and doesn't skip to the next page without doing that.

  2. I want the page to automatically move on to the next one as soon as the participant clicks on the link. This is to ensure that they don't click on the link more than once.

  3. I want a timestamp for when the participant clicks on the embedded link.

This is what I have so far: The command for it to tell me when the respondent clicks on the link works. (t1shared=1 if respondent clicks). But the Hide Next Button command isn't working.

Qualtrics.SurveyEngine.addOnload(function()
{ jQuery("#extLink").click(function(event) {
  Qualtrics.SurveyEngine.setEmbeddedData("t1.shared","1"); });
});
Qualtrics.SurveyEngine.addOnReady(function()
{ var qobj = this;
qobj.hideNextButton();
jQuery("#extLink").click(function(event) { qobj.showNextButton(); }) 
});
Qualtrics.SurveyEngine.addOnUnload(function()
{/*Place your JavaScript here to run when the page is unloaded*/}

Hello, Create embedded variable "timestamp" and try this code
Qualtrics.SurveyEngine.addOnReady(function() {
var qobj = this;
qobj.hideNextButton();
jQuery("#extLink").click(function(event) {
Qualtrics.SurveyEngine.setEmbeddedData("t1.shared", "1");
Qualtrics.SurveyEngine.setEmbeddedData("timestamp", new Date());
qobj.clickNextButton(); 
}) ;
});


Thanks, I will just try this. When I add "timestamp" as a variable, do I set a value for it?



Hello
Using your code I have been able to make the hide.Next Button and the click.Next Button commands work. Thanks.
But now Qualtrics isn't recording "1" for participants who clicked on the link. In fact, irrespective of whether people clicked or not, I get a value of "0" when I export the data. How can I fix that?


https://community.qualtrics.com/discussion/comment/38541#Comment_38541Hello
Using your code I have been able to make the hide.Next Button and the click.Next Button commands work. Thanks.
But now Qualtrics isn't recording "1" for participants who clicked on the link. In fact, irrespective of whether people clicked or not, I get a value of "0" when I export the data (my embedded variable t2.shared has set value to 0).
This is important for me because I have two links to be clicked. On the same page, there are two questions, each with a link. I am asking participants to click on any one of the two. I want Qualtrics to tell me which link they clicked on. Here is what I have so far in the code:

Screen Shot 2021-06-23 at 15.30.37.pngScreen Shot 2021-06-23 at 15.30.47.png


Hi, Please confirm if you're setting up embedded field at the top of survey flow.


Leave a Reply