Track whether a link is clicked in qualtrics even a respondent leaves for the opened new page | XM Community
Solved

Track whether a link is clicked in qualtrics even a respondent leaves for the opened new page

  • 23 November 2018
  • 49 replies
  • 2612 views


Show first post

49 replies

Userlevel 7
Badge +27

https://www.qualtrics.com/community/discussion/comment/37513#Comment_37513No, I don't think you can update embedded data fields after you reach the end of survey message.

Userlevel 5
Badge +11

https://www.qualtrics.com/community/discussion/comment/37517#Comment_37517TomG , do you think it would be possible to therefore do it via a Question but to trick Qualtrics in thinking it's reached the end of the survey before it's actually reached the end?

Userlevel 7
Badge +27

https://www.qualtrics.com/community/discussion/comment/37519#Comment_37519The issue is you need to make sure the Next button is clicked on the last page to complete the response.
You could ask a two choice forced response question. For the 'link' answer you set an embedded variable in the survey flow then redirect to the link. For the other answer, you just go to the end of survey message.

Userlevel 5
Badge +11

HI TomG
I guess that would work, thanks. I'm thinking too that you'd then do a JS event listener to click the next button automatically when one of the buttons is clicked. You'd then setup 2 End of Surveys messages, one is a redirect and the other one if a normal end of survey message oh and I guess make the buttons look like normal URL links / images (some messy css changes required no doubt!)
I did also have another idea... I spoke to our tech team and they suggested that they could do a redirect service via our website, so when you click on the link in the EOS message, our web server would action the redirect and record it in our web server logs. I'd then extract the logs and tidy up. This would mean it would be pretty flexible and simple on the survey side, I just use a custom URL link.

eg. for tripadvisor I'd use a URL: www.mycompanysite.com/RedirectMeTo//SurveyID/ResponseID
The web server log will then allow me to matchup the redirect to the response say through a CX dashboard.

Assuming our systems don't go down(!), can you think of any issues I might have with a redirect? I don't know much about URL referrers or redirects and so it's a little bit unknown as to whether this could be problematic over time.

Thanks

Rod Pestell

Badge +1

Hi TomG ,
Thanks for your very helpful posts above. I've tried to follow your explanation exactly, but similar to Hillary and Katha , I am only ever seeing clicked = 0, regardless of whether the link is clicked or not.
Any trouble-shooting you can provide would be much appreciated!
Below is a screenshot showing that I define clicked=0 as an embedded data variable at the top of my survey flow (before the block where the link is embedded).
set_embedded_data.pngHere is the HTML code where the link is defined:
html.pngAnd the associated javascript for that question block:
javascript.pngI've tried with and without adding jQuery("#NextButton").click(); and neither approach generated clicked = 1 when the link was clicked.
Thanks again,
Anna

Userlevel 7
Badge +27

Your jQuery selector is incorrect. It should be

jQuery("#extLink")
.

Badge +2

Hi TomG - Many thanks for this resource!
I seem to be having the opposite problem of most folks here in that my click-tracking works fine when the respondent does click the link (i.e., it records a '1'), but does not record a '0' when the respondent doesn't click the link - it shows as blank in the CSV output. How to make sure the non-clickers get a recorded '0' in this column of the output?
JS code for question:
image.png
Link Source:
Click HERE">http://www.vaccines.gov">HERE to open a new window showing the nearest available COVID-19 vaccine with information to easily make an appointment.

Embedded:
image.png
Any help is much appreciated!!
-Scott

Userlevel 7
Badge +27

https://community.qualtrics.com/XMcommunity/discussion/comment/44437#Comment_44437Is TrackClick set to 0 in the survey flow where it will get initialized for all respondents (i.e., at the beginning of the flow and not inside any branches)?

Badge +2

https://community.qualtrics.com/XMcommunity/discussion/comment/44438#Comment_44438Thanks, Tom. I had the Embedded Data as its own block right above the block with the hyperlink. I just now tried moving that Embedded Data to the very top, and still, it did not register a non-click as a '0' in the output.

image.png

Userlevel 7
Badge +27

https://community.qualtrics.com/XMcommunity/discussion/comment/44442#Comment_44442I'm not sure, but it may the app you are using to look at the csv. Does it show 0's when you look at that field in Data & Analysis tab?

Badge +2

https://community.qualtrics.com/XMcommunity/discussion/comment/44443#Comment_44443Actually, this new item 'TrackClick' doesn't show up at all on the Data & Analysis tab - only in the exported CSV. Unless you have other ideas, I'll likely just deal with this during data cleaning, such as re-coding missing responses as '0'. Many thanks for your time!
-Scott

Userlevel 5
Badge +11

https://community.qualtrics.com/XMcommunity/discussion/comment/44446#Comment_44446Can you send a screen shot Graups ?
And can you confirm that you know how to add in columns of embedded fields into the Data & Analysis tab? If not, reply and will send screen shot.

Badge +2

https://community.qualtrics.com/XMcommunity/discussion/comment/44455#Comment_44455Hi Rod - Thanks for your help. This is my first time trying to add in columns of embedded fields - this is likely the root of the issue.
I have, however, resolved the issue by dumb luck. In case it helps anyone else, my issue seems to have been that my Embedded data was set to 'text' and by clicking the Options button and changing this to 'Number' I have resolved the issue.
image.png
Many thanks!!

-Scott

Userlevel 5
Badge +11

Ah yes - that issue! Even though the setting of the variable is not shown (at first) it is actually set to textset (as a default) if I recall one of my support ticket responses.

However, I wouldn't have thought that would have caused an issue as it's not like you are adding a value to another value. A textset variable can be a number or a letter.

To add an embedded field column in the data&analysis tab (that has been created in a survey flow), you just click on the + on one of the columns at the top and then navigate through to the embedded field drop down list and find your embedded field.

It might be worth trying to change it back to textset and seeing if the numbers disappear. You can then change it back to number again and the numbers will come back. But I would have thought changing it to textset won't make a difference. We will see!

Thanks
Rod Pestell

Badge +2

https://community.qualtrics.com/XMcommunity/discussion/comment/44507#Comment_44507To further close the loop I think part of my own personal issue was that when exporting the CSV, I was choosing the option to show numeric values, so because I had it set to text, it was just showing as blank. Maybe I know just enough (too little) to be dangerous on this great platform :)
Thanks again for your help!

Userlevel 2
Badge +2

@daniel_navarro,

I'm the author of the Stackoverflow post you cited. Embedded variables don't get saved on the Qualtrics server until the page is submitted. So, you just need to add a line to the script to click the Next Button. I've updated it to use jQuery instead of prototypejs:
```
Qualtrics.SurveyEngine.addOnload(function() {
jQuery('#extLink').click(function(event) {
Qualtrics.SurveyEngine.setEmbeddedData("clicked", "1");
jQuery("#NextButton").click();
});
});
```

How would I use this if I have 3 different links? ex: 3 different questions will have their own URL and I need to know if they are clicked

Userlevel 1
Badge +1

Since some people found this a bit tricky, I made a video demonstrating the whole process for creating an embedded variable to track whether someone clicked a URL link. I know I always appreciate a visual aid, so hopefully this helps others. 

Here's the video: https://youtu.be/0FLojfSM40g
 

Badge +1

There are a number of different ways to do it. To simplify, let's say the choiceid of the choice you are interested in is 1. Then:
```
jQuery("#"+this.questionId+" input[choiceid=1]").click(function() { ... etc...
```

Dear @TomG,

I have tried to record how many times each answer choice in a multiple-choice question is being clicked and followed the solution mentioned here. I assigned an ID to each option as follows:
<p id="decrease">Decrease by 1 vehicle</p>
<p id="remain"> Remain the same</p>
<p id="increase">Increase by 1 vehicle</p>
I also defined three embedded data

However, the provided code does not seem to work as intended; it only shows zero as the result. Could you please help me identify what I did wrong? Thank you so much.

var clickedDecrease = parseInt(Qualtrics.SurveyEngine.getEmbeddedData("clickeddecrease"));
var clickedRemain = parseInt(Qualtrics.SurveyEngine.getEmbeddedData("clickedremain"));
var clickedIncrease = parseInt(Qualtrics.SurveyEngine.getEmbeddedData("clickedincrease"));

jQuery(document).ready(function() {
  jQuery("#"+this.questionId+" input[choiceid=decrease]").click(function() {
    clickedDecrease++;
    Qualtrics.SurveyEngine.setEmbeddedData('clickeddecrease', clickedDecrease);
  });

  jQuery("#"+this.questionId+" input[choiceid=remain]").click(function() {
    clickedRemain++;
    Qualtrics.SurveyEngine.setEmbeddedData('clickedremain', clickedRemain);
  });

  jQuery("#"+this.questionId+" input[choiceid=increase]").click(function() {
    clickedIncrease++;
    Qualtrics.SurveyEngine.setEmbeddedData('clickedincrease', clickedIncrease);
  });
});

Userlevel 7
Badge +27

@Reihan,

Your selectors are wrong because they aren’t inputs and they don’t have a choiceid attribute. You can use ids, for example:

jQuery("#decrease").click(function() { …

If the elements are just paragraphs it isn’t going to be obvious that clicking them will do anything. You may want to consider changing them to buttons or links or formatting them to look like links.

Badge +1

@Reihan,

Your selectors are wrong because they aren’t inputs and they don’t have a choiceid attribute. You can use ids, for example:

jQuery("#decrease").click(function() { …

If the elements are just paragraphs it isn’t going to be obvious that clicking them will do anything. You may want to consider changing them to buttons or links or formatting them to look like links.

Thank you @TomG, for your response. This code only works if the respondent clicks on the option's text. If they click on the option's button, it cannot record the respondent's click. Is it possible to record the button click for an option?

var clickedDecrease = parseInt(Qualtrics.SurveyEngine.getEmbeddedData("clickeddecrease")) || 0;
var clickedRemain = parseInt(Qualtrics.SurveyEngine.getEmbeddedData("clickedremain")) || 0;
var clickedIncrease = parseInt(Qualtrics.SurveyEngine.getEmbeddedData("clickedincrease")) || 0;


jQuery("#decrease").click(function(event) {
clickedDecrease++;
Qualtrics.SurveyEngine.setEmbeddedData('clickeddecrease', clickedDecrease);
console.log("Clicked Decrease: " + clickedDecrease);
});

jQuery("#remain").click(function(event) {
clickedRemain++;
Qualtrics.SurveyEngine.setEmbeddedData('clickedremain', clickedRemain);
console.log("Clicked Remain: " + clickedRemain);
});

jQuery("#increase").click(function(event) {
clickedIncrease++;
Qualtrics.SurveyEngine.setEmbeddedData('clickedincrease', clickedIncrease);
console.log("Clicked Increase: " + clickedIncrease);
});

 

Userlevel 7
Badge +27

@Reihan,

I misunderstood and didn’t realize they were choices. Assuming they are vertical choices and NOT simple layout, then you can do:

jQuery("#decrease").closest(".Selection").click(function() { …

 

Badge +1

@Reihan,

I misunderstood and didn’t realize they were choices. Assuming they are vertical choices and NOT simple layout, then you can do:

jQuery("#decrease").closest(".Selection").click(function() { …

 

@TomG Thank you for your quick response. It works, but it's counting twice for every click. like

first click:
Clicked Decrease: 1
Clicked Decrease: 2


Clicked Remain: 1
Clicked Remain: 2

second click:
Clicked Decrease: 3
Clicked Decrease: 4

Userlevel 7
Badge +27

@Reihan,

I misunderstood and didn’t realize they were choices. Assuming they are vertical choices and NOT simple layout, then you can do:

jQuery("#decrease").closest(".Selection").click(function() { …

 

@TomG Thank you for your quick response. It works, but it's counting twice for every click. like

first click:
Clicked Decrease: 1
Clicked Decrease: 2


Clicked Remain: 1
Clicked Remain: 2

second click:
Clicked Decrease: 3
Clicked Decrease: 4

I think it is because you are in preview mode.

Badge +1

I’m finding that this all works well for most of my internal survey testing. But when one of my colleagues tests my survey, the links that he clicks are inconsistently recorded. I’ve watched him click links, have those links take him to external sites in new browser windows, and finish the survey -- and then when I check the data, I see “0”’s where there should be “1’s.” 

So far I haven’t found anything that distinguishes him from everyone else for whom it’s working consistently (Mac vs. Windows, web browser, incognito mode). Can anyone think of another potential explanation for his links being inconsistently recorded? 

Leave a Reply