Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Is it possible to pass the token in the url and store as a hidden field?

Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64119

  • dataguru
  • dataguru's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Karma: 0
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
The administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64142

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
1) Yes, when you send the token to the respondent (using the built-in mail feature) the URL will look something like:
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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64156

  • dataguru
  • dataguru's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Karma: 0
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}
Last Edit: 2 years 8 months ago by dataguru.
The administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64181

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
I haven't tested but maybe something like:
<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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64205

  • dataguru
  • dataguru's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Karma: 0
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
<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
<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 administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64206

  • dataguru
  • dataguru's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Karma: 0
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.
The administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64207

  • dataguru
  • dataguru's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Karma: 0
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.
$(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>");
 
	});
I suppose it might help if I was more familiar with javascript.
The administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64233

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
It's not available in the endpage.pstpl.
I'm not sure why you would want an opt-out link on the end page, the respondents will already have completed the survey.

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).
<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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64244

  • dataguru
  • dataguru's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Karma: 0
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
The administrator has disabled public write access.

Re: Is it possible to pass the token in the url and store as a hidden field? 2 years 8 months ago #64254

  • dataguru
  • dataguru's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 36
  • Karma: 0
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
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.337 seconds
Donation Image