====== Multi-Wave Surveys with Self-Recruited Respondents ======

As a general rule, participants' email addresses have to be known beforehand when carrying out a multi-wave survey as the respondents have to be invited, at some point, to a survey wave at a later date. However, if participants have been recruited via links on a website, social media or advertising banners, then their email addresses are not known beforehand. This chapter explains different technical solutions that guarantee the respondents' anonymity. 

The two options differ from each other, if the participant has to disclose their email address: either the participant is asked for their email address at the beginning, or at the end of the first questionnaire.

If the participant has to "register" for the study beforehand then this is a particular obstacle. The danger being that many participants will not want to take part at all due to concerns about anonymity. An advantage of requesting the email address a-priori is, however, that taking part in the survey is only possible after specifying a valid email address - if there is a typo or the person does not want to give an email address, then they will not be able to access the first questionnaire. There are, therefore, less dropouts between survey waves.  

Another advantage of requesting the email address in advance is being able to work with ''[[:en:create:functions:mailresume|mailResume()]]'' and interruption pages. This enables all of a participant's data to be collected in a data record at the same time.



===== Request Email Address at the Beginning =====

  * A mailing is creating beforehand for each survey wave (even for the first) (**Invitation Mailings** -> **Mailings**). In the //Questionnaire URL// tab, which questionnaire should be used for the individual waves is set.
  * The participant has to register their email address for the study beforehand. An additional questionnaire is created in the survey project in order to do so (**Compose Questionnaire** -> //Further Questionnaires//). This questionnaire only contains a question type "[[:en:create:questions:opt-in|Opt/in for Mailing List]]".
  * After this there are two options:
  

==== Manual Sending of Invitations ====

This makes sense if participants should fill in the questionnaire around the same time. The period of the survey continues over several days as not everyone will respond to the email immediately -- in particular, data collected over a longer period of recruitment are more comparable in terms of time than when mailings are dispatched automatically (see below).

  * Adresses are collected over a period of time -- and when there are enough addresses in the **Address List**, the first mailing (invitation to take part in the first questionnaire) will be sent to everyone.
  * Further invitations will be manually (and at the same time for everyone) sent using the mailing function.


==== Automatic Sending of Invitations ====

This option is sensible when participants should start the survey straightaway after registering.

  * In the Opt-in question in //Personalized link from//, the first mailing is selected. This means the participant will begin with the first questionnaire directly after confirming their email address.
  * At the end of the questionnaire, the PHP function ''[[:en:create:functions:mailschedule|mailSchedule()]]'' (for separate data records) or ''[[:en:create:functions:mailresume|mailResume()]]'' (if all waves should be saved in one data record) will be used in order to schedule the time-controlled sending of the next mailing(s). Independent of which two functions you use, specify ''false'' for the first parameter and the ID of the mailing for the second parameter.
 
===== Request Email Address at the End of the First Questionnaire =====

  * An "[[:en:create:questions:opt-in|Opt-in for Mailing List]]" question type is also needed for this option. This is placed at the end of the first questionnaire -- it makes sense to include a reference to the next waves of survey.
  * In addition, you need another questionnaire (**Compose Questionnaire** -> //Further Questionnaires//, which takes care of the time-controlled sending of mailing(s). If you want to send invitations manually using the mailing function, this additional questionnaire is obviously not necessary.
  * Create a mailing for each survey wave (even for the first) (**Invitation Mailings** -> **Mailings**). In the //Questionnaire Link// tab, which questionnaire should be used for the individual waves is set. For the first mailing, the link does not point to the first questionnaire, but to the additional questionnaire which takes care of the time-controlled sending.
  * The scheduling of the time-controlled mailing occurs by using the ''[[:en:create:functions:mailschedule|mailSchedule()]]'' function. Give ''false'' for the first parameter in this function, the ID of the mailing for the second parameter.
  * Choose this particular mailing in the opt-in question in //Personalized link from//. The sending of further invitation emails will then be executed immediately on completion of the opt-in confirmation. 

===== Example =====

The following example demonstrates the use of ''[[:en:create:functions:mailresume|mailResume()]]'' and ''[[:en:create:functions:mailrevoke|mailRevoke()]]'' for a survey with three measuring periods, where all data belonging to a participant will be stored in the same line of data. Possible areas of application are, for example, a follow-up measurement, intervention study, or pre/post analysis.  

==== Functions ====

  * Participants automatically receive an invitation to the next time of measurement (next part of the questionnaire) after a certain time and will not have access to the questions in the next part of the questionnaire prior to this.
  * Participants automatically receive reminder emails, if they do not respond to the first invitation to the next time of measurement within a certain amount of time.

==== Preparation ====

All parts in the questionnaire are arranged one after the other in one questionnaire. "Mailings" is set as the access mode for the questionnaire.

If the participants' email addresses are __not__ known in advance, a second questionnaire with a question [[:de:create:questions:opt-in|Opt-in for Email Distribution List]] is created. "public" is set as the access mode for this questionnaire. 

Create a mailing (ID 1 in the example) which sends a invitation to the second time of measurement after 7 days. In the "Reminder/Follow-up" tab, the "Type of follow-up" is set so that there is a reminder or follow-up. In the email text the %link% placeholder has to be used (as usual).

Create two more mailings (ID 2 and 3 in the example). These serve as a reminder, if the participant is yet to fill in the second part of the questionnaire after 9 or 11 days (settings are the same as in mailing 1).

Create three more mailings (ID 4-6 in the example): An invitation to the third part and two reminders (settings are the same as in mailing 1). 


==== PHP Code for Time 1 ====

The values (numbers) in the PHP code are to be adapted to each study, in particular regarding time intervals and mailing IDs.

In **Compose Questionnaire**, an additional page (page interruption) is inserted between the first and second part of the questionnaire. The following PHP code is put on this page.


<code php>
// Time which the page interruption was first accessed in stored in the $timepart1 variable.
// isset() und registerVariable() prevent this time being changed when the page is accessed again (e.g. if the page is refreshed) and/or emails being duplicated.
if (!isset($timepart1)) {
  // store time
  $timepart1 = time();
  registerVariable($timepart1);

  // Send invitation with mailing ID 1 for the second period of measurement after 7 days
  // Time interval always given in seconds 7 x 24 x 3600 seconds = 7 days
  mailResume(false, 1, 7 * 24 * 3600);

  // Send first reminder email with mailing ID 2 after 9 days
  // (i.e. two days after the first invitation to the second period of measurement)
  mailResume(false, 2, 9 * 24 * 3600);

  // Send second reminder email with mailing ID 3 after 11 days
  // (i.e. four days after the first invitation)
  mailResume(false, 3, 11 * 24 * 3600);
} 

// Check how much time has passed since the page was first accessed
if ((time() - $timepart1) < 7 * 24 * 3600) {
  // Display page interruption if this is less than 7 days,
  // so participants cannot see the questions in the second period of measurement before this time has passed.
  option('resume', true); // No indication that the interview is being resumed.
  option('nextbutton', false); // Hide Next button (Interview interrupted)
  text('end1');  // Maybe display a farewell indicating the end of the first part of the interview.
} else {
  // If the participant returns after 7 days, making the current time minus the new time variable
  // more than 7 days, then the survey will be resumed on the next page.
  goToPage('next');
}
</code>


==== PHP Code for Time 2 ====

A new page interruption is placed between the second and third parts of the questionnaire. To a great extent, the PHP code complies with the code above. However, mailRevoke() ensures that potential outstanding reminders (mailings ID 2 and 3) are no longer sent.


<code php>
// New time variable for the second period
if (!isset($timepart2)) {
  $timepart2 = time();
  registerVariable($timepart2);
  // Delete reminder emails if they are outstanding
  mailRevoke(false, 2);
  mailRevoke(false, 3);

  // Send invitation with mailing ID 4 to the third period of measurement after 7 days
  mailResume(false, 4, 7 * 24 * 3600);

  // First reminder email after 9 days
  mailResume(false, 5, 9 * 24 * 3600);

  // Second reminder email after 11 days
  mailResume(false, 6, 11 * 24 * 3600);
} 

// Pause for 7 days
if ((time() - $timepart2) < 7 * 24 * 3600) {
  option('resume', true);
  option('nextbutton', false);
} else {
  goToPage('next');
}
</code>

==== PHP Code for Time 3 ====

Any reminder emails that are yet to be sent have to be deleted on the penultimate page of the questionnaire.

<code php>
  mailRevoke(false, 5);
  mailRevoke(false, 6);      
</code>

==== Tips ====

**Important:** Do not place any questions on the interruption pages - the above PHP code only shows text (thanks, farewell and information regarding the next period of measurement).

**Note:** The invitation to the third part of the questionnaire takes place in relation to the time the participant follows the invitation to part 2. Therefore, if they fill do not fill out part 2 until 10 days after part 1, the invitation to part 3 will be sent 17 days after part 1 has been filled out. Alternatively, you could include all (!) invitations and reminders right at the end of part 1. The filter at the end of part 2 would then have to refer to ''$timepart1'' instead of ''$timepart2''.

**Note:** The attendance status for the follow-up and reminder mailings are __not__ apparent in the address list (mailings are in gray). The attendance status will only be displayed for a potential Opt-in mailing. However, in order to get a feeling for the attendance status, you are able to look at data that has already been collected. Individual attribution using the SERIAL variable is only possible if email addresses have been imported using the "Personalized entry" setting for "Anonymity".

**Tip:** The same reminder emails can be used multiple times (with a general reminder text). In the above example, mailing ID 2 could be sent for all reminders (i.e. instead of mailings ID 3, 5 and 5).



 