0

The link provided here answers how Qualtrics records if an external link is clicked or not. Tracking when an external link is clicked in Qualtrics with javascript

But can I know when or the exact time that the link is clicked? What is the Javascript I can use? Thanks!

Update 1:

Qualtrics.SurveyEngine.addOnload(function() {
    $('extLink').on('click', function(name, event) {
        Qualtrics.SurveyEngine.setEmbeddedData('clicked', '1');
        Qualtrics.SurveyEngine.setEmbeddedData('clicked at ' + new Date(), '1');
        });
});

Update 2: Embedded data part:

clicked=0${date://CurrentDate/c}
Qualtrics.SurveyEngine.addOnload(function() {
    $('extLink').on('click', function(name, event) {
        Qualtrics.SurveyEngine.setEmbeddedData('clicked at ' + new Date().toGMTString(), '1');
        });
});
  • Have you tried doing `Qualtrics.SurveyEngine.setEmbeddedData('clicked at ' + new Date(), '1');`? – Henrique Sabino Jun 17 '20 at 17:31
  • Did I use this code below correctly (please see the updated question)? It didn't work. I'm sorry that it's my first time using javascript in Qualtrics. – Shirley Wu Jun 17 '20 at 18:19
  • I meant that you could try to remove the old `Qualtrics.SurveyEngine.setEmbeddedData('clicked', '1');` and add only the `Qualtrics.SurveyEngine.setEmbeddedData('clicked at ' + new Date(), '1');` I mentioned. If the embedded data needs to be a `string` try using `Qualtrics.SurveyEngine.setEmbeddedData('clicked at ' + new Date().toGMTString(), '1');` – Henrique Sabino Jun 17 '20 at 18:26
  • 1
    Thank you so much! It worked! – Shirley Wu Jun 17 '20 at 18:51
  • Ok, I'll make a proper answer here so your question can be marked as answered – Henrique Sabino Jun 17 '20 at 18:52

1 Answers1

0

Try using this piece of code here:

Qualtrics.SurveyEngine.addOnload(function() {
    $('extLink').on('click', function(name, event) {
        Qualtrics.SurveyEngine.setEmbeddedData('clicked at ' + new Date(), '1');
        });
});

Or this one if you want your embedded data to be of a string type

Qualtrics.SurveyEngine.addOnload(function() {
    $('extLink').on('click', function(name, event) {
        Qualtrics.SurveyEngine.setEmbeddedData('clicked at ' + new Date().toGMTString(), '1');
        });
});
Henrique Sabino
  • 546
  • 3
  • 19