- Posts: 13
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Is it possible to pass the token in the url and store as a hidden field?
- dataguru
- Topic Author
- Offline
- New Member
Less
More
12 years 8 months ago #64119
by dataguru
Is it possible to pass the token in the url and store as a hidden field? was created by dataguru
I installed Limesurvey Friday and have customized a template and built my first survey. You guys have done a really great job building it!!
Before I activate the survey for testing:
Is it possible to pass the token in the url and store as a hidden field rather than asking the user to enter it?
The token value is stored with the survey data when that's written? (I'll need to use it to link back to some other data used for reporting.)
Also, I'd like to embed the opt out code in the survey template, so the user can opt out at any time. Does the opt out code automatically include the token? or is there a better way to do that?
Thanks!
Betty
Before I activate the survey for testing:
Is it possible to pass the token in the url and store as a hidden field rather than asking the user to enter it?
The token value is stored with the survey data when that's written? (I'll need to use it to link back to some other data used for reporting.)
Also, I'd like to embed the opt out code in the survey template, so the user can opt out at any time. Does the opt out code automatically include the token? or is there a better way to do that?
Thanks!
Betty
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
12 years 8 months ago #64142
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Is it possible to pass the token in the url and store as a hidden field?
1) Yes, when you send the token to the respondent (using the built-in mail feature) the URL will look something like:
2) If the survey is non-anonymous the token (and custom attributes) will be stored in the data and can be exported with all other results.
3) I think you would need to use the {url} and {TOKEN} keywords to create the string in your template. See docs.limesurvey.org/The+template+editor&...+LimeSurvey#Keywords and docs.limesurvey.org/The+template+editor&...+LimeSurvey#Keywords .
Code:
http://yourSurveySite.com/limesurvey/index.php?lang=en&sid=12345&token=678
2) If the survey is non-anonymous the token (and custom attributes) will be stored in the data and can be exported with all other results.
3) I think you would need to use the {url} and {TOKEN} keywords to create the string in your template. See docs.limesurvey.org/The+template+editor&...+LimeSurvey#Keywords and docs.limesurvey.org/The+template+editor&...+LimeSurvey#Keywords .
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- dataguru
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
12 years 8 months ago - 12 years 8 months ago #64156
by dataguru
Replied by dataguru on topic Is it possible to pass the token in the url and store as a hidden field?
Thanks Tony!!
so something like:
To opt out of the survey <a href="{url}?token={TOKEN}">click here</a>.
or
To opt out of the survey <a href="{OPTOUTURL}">click here</a>.
I added 2nd version using {OPTOUTURL} right before the first end div in theendpage.pstpl
and when I preview the survey, the link is:
eteam.ou.edu/survey/{OPTOUTURL }
so something like:
To opt out of the survey <a href="{url}?token={TOKEN}">click here</a>.
or
To opt out of the survey <a href="{OPTOUTURL}">click here</a>.
I added 2nd version using {OPTOUTURL} right before the first end div in theendpage.pstpl
and when I preview the survey, the link is:
eteam.ou.edu/survey/{OPTOUTURL }
Last edit: 12 years 8 months ago by dataguru.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
12 years 8 months ago #64181
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Is it possible to pass the token in the url and store as a hidden field?
I haven't tested but maybe something like:
Code:
<a href="http://yourSurveySite/limesurvey//optout.php?lang=en&sid=12345&token={TOKEN}">Opt out</a>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- dataguru
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
12 years 8 months ago #64205
by dataguru
Replied by dataguru on topic Is it possible to pass the token in the url and store as a hidden field?
I know now why {OPTOUTURL} didn't work. It's not available in the endpage.pstpl. {TOKEN} isn't available there either.
I also tried using php in the template
and
but it keeps removing the <?
I also tried using php in the template
Code:
<p><a href="http://eteam.ou.edu/survey//optout.php?lang=en&sid=<?php echo $scid; ?>&token=<?php echo $clienttoken; ?>">Click here to opt out of this survey</a></p>
and
Code:
<p><a href="http://eteam.ou.edu/survey//optout.php?lang=en&sid=<?php echo $_GET["sid"]; ?>&token=<?php echo $_GET["token"]; ?>">Click here to opt out of this survey</a></p>
but it keeps removing the <?
The topic has been locked.
- dataguru
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
12 years 8 months ago #64206
by dataguru
Replied by dataguru on topic Is it possible to pass the token in the url and store as a hidden field?
hmmmm perhaps using javascript.
docs.limesurvey.org/Workarounds%3A+Manip...vious_To_Top_Of_Page
I'd think it would be possible to add some javascript to display the optout option.
docs.limesurvey.org/Workarounds%3A+Manip...vious_To_Top_Of_Page
I'd think it would be possible to add some javascript to display the optout option.
The topic has been locked.
- dataguru
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
12 years 8 months ago #64207
by dataguru
Replied by dataguru on topic Is it possible to pass the token in the url and store as a hidden field?
I think I suck at this.
I tried adding this at the end of the template.js file. Nothing appeared to happen when I previewed the survey.
I suppose it might help if I was more familiar with javascript.
I tried adding this at the end of the template.js file. Nothing appeared to happen when I previewed the survey.
Code:
$(document).ready(function() { // Insert a new div after the progress bar $('<div id="navigator2" />').insertAfter('#progress-wrapper'); // Style the new div $('#navigator2').css({ 'text-align':'center' }); // Insert opt out url in the new div document.write("<p>here it is</p>"); });
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
12 years 8 months ago #64233
by tpartner
You can't use keywords in template.js. They are replaced before the page loads by the core PHP.
I think you may need to set up your survey to use JavaScript and add something like this to the source of every group description (if using group-by-group) or every question (if using question by question).
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Is it possible to pass the token in the url and store as a hidden field?
I'm not sure why you would want an opt-out link on the end page, the respondents will already have completed the survey.It's not available in the endpage.pstpl.
You can't use keywords in template.js. They are replaced before the page loads by the core PHP.
I think you may need to set up your survey to use JavaScript and add something like this to the source of every group description (if using group-by-group) or every question (if using question by question).
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Find the survey ID if($('input#fieldnames').length != 0) { var fieldNames = $('input#fieldnames').attr('value'); var tmp = fieldNames.split('X'); var sID = tmp[0]; } // Insert a new div after the progress bar $('<div id="optOutLink" />').insertAfter('#progress-wrapper'); // Style the new div $('#optOutLink').css({ 'text-align':'center' }); // Insert opt out url in the new div $('#optOutLink').html('<a href="optout.php?lang=en&sid='+sID+'&token={TOKEN}">Click here to opt out</a>'); }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- dataguru
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
12 years 8 months ago #64244
by dataguru
Replied by dataguru on topic Is it possible to pass the token in the url and store as a hidden field?
Sorry for being such a newby,
to me endpage.pstpl looked like it displays the bottom of each page, not the last page.
I just want to it display on the each survey page so the user is able to opt out at any time.
That really helps. So it didn't display last time because I didn't enable javascript. duh.
Thanks so much for your help.
The reason I'm doing this is because our IRB wants them to be able to opt out at any time. It just occurred to me that I could add verbage to the e-mail telling then they can click on that opt out link in the e-mail at any time during the survey to opt out. That might satisfy out IRB. The opt out link in the e-mail would work after someone had started their survey?
Betty
to me endpage.pstpl looked like it displays the bottom of each page, not the last page.
I just want to it display on the each survey page so the user is able to opt out at any time.
That really helps. So it didn't display last time because I didn't enable javascript. duh.
Thanks so much for your help.
The reason I'm doing this is because our IRB wants them to be able to opt out at any time. It just occurred to me that I could add verbage to the e-mail telling then they can click on that opt out link in the e-mail at any time during the survey to opt out. That might satisfy out IRB. The opt out link in the e-mail would work after someone had started their survey?
Betty
The topic has been locked.
- dataguru
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
12 years 8 months ago #64254
by dataguru
Replied by dataguru on topic Is it possible to pass the token in the url and store as a hidden field?
My idea for the e-mail didn't fly. Our IRB wants the opt out on each page of the survey.
I turned off the XSS-Filter in global.
Then inserted your javascript at the end of the template.js file using the template editor
I don't see it either on preview mode or on the active survey.
eteam.ou.edu/survey/index.php?lang=en&si...oken=7bgma49ipptxjfw
Any idea why it wouldn't be working?
Thanks,
Betty
I turned off the XSS-Filter in global.
Then inserted your javascript at the end of the template.js file using the template editor
I don't see it either on preview mode or on the active survey.
eteam.ou.edu/survey/index.php?lang=en&si...oken=7bgma49ipptxjfw
Any idea why it wouldn't be working?
Thanks,
Betty
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
12 years 8 months ago #64260
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Is it possible to pass the token in the url and store as a hidden field?
My script can't be added to template.js. It needs to be added to the source of a group description or a question.
The {TOKEN} keyword placeholder won't work in template.js (nor will any keyword placeholder).
The {TOKEN} keyword placeholder won't work in template.js (nor will any keyword placeholder).
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- dataguru
- Topic Author
- Offline
- New Member
Less
More
- Posts: 13
- Thank you received: 0
12 years 8 months ago #64262
by dataguru
Replied by dataguru on topic Is it possible to pass the token in the url and store as a hidden field?
Let's see if I can make it work there.\
Thanks for your assistance.
Betty
Thanks for your assistance.
Betty
The topic has been locked.