Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Fill participant table attributes through URL

More
4 years 3 months ago #191730 by asaha
i have created a participant table with 8 diff attributes [attribute_1, ... attribute_8}
I am trying to fill these attributes with some values, while having the survey set to be open for public registrating so that I can track the various traffic sources and campaigns.

is there a way to fill these attributes by passing them in a URl string say something like

limesurvey.com/index.php/781278?lang=en&...ttribute_1=mydayblog

so that i can store mydayblog under attribute_1 in participant table?
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #191734 by Joffm
What is the intention that you want to store in TOKEN_ATTRIBUTES?
If you pass the parameters you may grab it in a simple question of type "short text".

And how do you add the parameter if you

while having the survey set to be open for public registrating


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
More
4 years 3 months ago #191736 by asaha
@Joffm main purpose of storing in token_attribute is to ensure that i can capture which campaign a new registartion came from.

the survey can only be taken after registration, and email validation, so it's important that i have a token table active.

I could have used a short field to capture, but then the email validation is not a possibility and also same email can be used multiple times to access a survey.

is there a way to write into token table of a survey?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #191738 by DenisChenu
Replied by DenisChenu on topic Fill participant table attributes through URL
There are no included solution, and i don't know existing workaround solution

You allow register : you can create a plugin
1. Put url params in session in manual.limesurvey.org/BeforeRegister
2. Put the attributes in beforeTokenEmail / type : register

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago - 4 years 3 months ago #191753 by tpartner
Replied by tpartner on topic Fill participant table attributes through URL
You could load the URL parameters into the register form via JavaScript.

Something like this in your theme custom.js file:

Code:
function getURLParameter(name) {
  return decodeURI(
    (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
  );
}  
 
$(document).on('ready pjax:scriptcomplete',function(){
 
  if($('#register_attribute_1').length > 0) {
    $('#register_attribute_1').val(getURLParameter('attribute_1'));
  }
});


Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 3 months ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
More
4 years 3 months ago #191755 by asaha
Hi Tony,

this is what i am trying to do, but being unsuccessful so far. Do i need any kind of authentication to write into token table? or just making a change in theme js file will do the trick?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #191757 by tpartner
Replied by tpartner on topic Fill participant table attributes through URL
Try it. :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #191758 by DenisChenu
Replied by DenisChenu on topic Fill participant table attributes through URL

DenisChenu wrote: …i don't know existing workaround solution

tpartner wrote: You could load the URL parameters into the register form via JavaScript.


Lol :)

Thank you Tony !

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
More
4 years 3 months ago #191770 by asaha
Hi Tony,

Your method worked, but this means I have to make the fields visible for the respondent. And show whatever I am capturing through the URL.

Is there any other possibility of doing this with attributes hidden
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago - 4 years 3 months ago #191773 by tpartner
Replied by tpartner on topic Fill participant table attributes through URL
Hide the input with CSS. Something like this in your custom.css file:

Code:
#register_attribute_1 {
   display: none !important;
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 3 months ago by tpartner.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose