Adding JavaScript to the End Message in order to track clicks on external links | XM Community
Skip to main content

Dear community, 

I found a solution how to track clicks on external link when it is included in a question (e.g. here  https://community.qualtrics.com/custom-code-12/where-can-i-find-whether-participants-clicked-on-a-link-or-not-13806). 

However, I would like to track clicks when the external link is included in the end message.

How can I include the following JavaScript to the end message?

 

Qualtrics.SurveyEngine.addOnload(function() {

              jQuery('#extLink').click(function(event) {

                            Qualtrics.SurveyEngine.setEmbeddedData("clicked", "1");

                            jQuery("#NextButton").click();

              });

});

Will adding Embedded Data: clicked = 0, in the Survey Flow, before the end message containing the external link work? 

Thank you in advance for your helpful comments!

Best, 
Kor

You can add the script to the EOS message by putting it inside a <script> tag.  However, it isn’t going to work because you can’t update an embedded data field after the survey had been completed.


Adding on comment by @TomG, you can use update response API in the JS to first update the response and then redirect to required website. 


Thank you @TomG and @Shashi for your suggestions. 

@Shashi, could you please elaborate more on using the API? I have never used it and would appreciate more explanation.

Thank you!

Best, 
Kor


I would love to know how to use the API also please @Shashi!

 


Leave a Reply