I have a question. In my survey, I have an external link inserted. I want a value of 1 is recorded if the link is clicked; otherwise a value of 0 is recorded. I followed a instruction given on a website: https://stackoverflow.com/questions/38225021/tracking-when-an-external-link-is-clicked-in-qualtrics-with-javascript. It works very well if a respondent's response is recorded as complete. But suppose a respondent clicks the link and then leaves for the new page and never comes back, then his response is recorded as response in progress. And when I check his response, a value of 0 is recorded even though he clicks the link. Is there a way to deal with this? Thanks.
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.
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?
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.
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/
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
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).
Here is the HTML code where the link is defined:
And the associated javascript for that question block:
I've tried with and without adding jQuery("#NextButton").click(); and neither approach generated clicked = 1 when the link was clicked.
Thanks again,
Anna
Your jQuery selector is incorrect. It should be
jQuery("#extLink").
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:
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:
Any help is much appreciated!!
-Scott
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)?
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.
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?
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
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.
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.
Many thanks!!
-Scott
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
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!
@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
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
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
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+" inputtchoiceid=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+" inputichoiceid=increase]").click(function() {
clickedIncrease++;
Qualtrics.SurveyEngine.setEmbeddedData('clickedincrease', clickedIncrease);
});
});
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.
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
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);
});
@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() { …
@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() { …
first click:
Clicked Decrease: 1
Clicked Decrease: 2
Clicked Remain: 1
Clicked Remain: 2
second click:
Clicked Decrease: 3
Clicked Decrease: 4
@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() { …
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.
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?
@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();
});
});
```
Hi Tom, I encountered a new problem and hope to get your advice. I followed exactly what you suggested and the sent out the first survey trail link (say survey 1). The answer was recorded successfully as “completed the survey“ once people clicked the link and exited the page. But in my current round, I have just sent out another survey link (survey 2) by adding a few more quetsions. The last quetsion is still the same (ask people to click the link) using the exactly same code, but strangely, the answers were not tracked this time. People have to return to the survey and manaully click the “Next” button to submit the survey. I followed AI suggestion by changing the unique id from “mylink 1” (in suvey 1) to ”mylink 2” (in survey 2), but it still didn’t work! I wonder is it becasue in qualtrics, I am only allowed to use the same weblink once??? What should I do the next…I’ve coped my code below.. It will be wonderful if I cna get your help to fix this. Thank you!
Qualtrics.SurveyEngine.addOnload(function()
{
jQuery('#mylink2').click(function(event){
Qualtrics.SurveyEngine.setEmbeddedData("tracked", "1");
jQuery("#NextButton").click();
});
/*Place your JavaScript here to run when the page loads*/
});
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*/
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.