formR documentation

chain simple forms into longer runs, use the power of R to generate pretty feedback and complex designs

Most documentation is inside formr – you can just get going and it will be waiting for you where you need it.
If something just doesn't make sense or if you run into errors, please let us know.

Getting Started


Creating Studies

To create studies, sign up with your email address. With a referral token from the people who run this instance, your account can create studies once you've confirmed your address. Without one, sign up, then ask the people who run this instance for the rights.

Your first study

A study is a chain of modules that each participant goes through. The smallest one is a survey followed by a Stop Point. This is how you get there:

  1. Write your survey in a spreadsheet, one item per row: its type, a name and the label participants read (see Survey Spreadsheet and the item types). End each page with a row of type submit. Copying our example sheet is the quickest start.
  2. Give the file the name the survey should have, e.g. big5.xlsx. The name starts with a letter and has 3 to 65 letters, digits and underscores, so no spaces. What follows a dash is dropped: big5-v2.xlsx is big5 too. Your results and your R code use this name, so pick one that says what the survey is.
  3. In the admin, go to Surveys → Create new Survey and upload the file, or import a Google Sheet shared by link (it takes the sheet's name). If the page offers a choice of Engine, leave it as it is for a classic survey. v2 gives you a survey that doesn't reload between pages, and showifs written in JavaScript (Form (v2)).
  4. If formr finds a mistake in the sheet, it says where. Correct it and upload again. Then open the survey (Surveys → its name) and click Test Survey to fill it out once. The same menu has its settings and, later, its results. Hover over the menu for hints.
  5. Go to Runs → Create new Run (the admin calls a study a run). Give the study a name of 3 to 45 letters, digits and dashes, starting with a letter. Participants see it in the study's address.
  6. You are now on Edit Run. The row of icons at the bottom adds modules (hover over an icon for its name). Click Add Survey, pick your survey from the list and click Save. Then click Add a Stop Point, write a thank-you text and save it. Every study needs a Stop Point at its end, or participants who finish see an error.
  7. Click Test Run in the study's menu and go through the study as a participant would. What you answer is marked as a test. formr's counts leave it out, but your downloads contain it.
  8. When it's ready, set Publicness, at the top of Edit Run, to People who have the link can access. Your study is then open at https://study.researchmixtape.com/YourStudyName/.

Written as positions, the way these pages describe studies, you now have:

Pos. 10. a survey called big5.
Pos. 20. a stop point that thanks participants.

From here, the Guides show how to ask for consent, show items only to some participants, run a diary and get your data out.

Setting up your own formr instance

To run formr on a server of your own, see Running your own instance in the Guides.

Guides


Answers to the questions we get asked most. Pick a question, or read a whole guide.

New to formr? Start here:

Common questions

Where your study runs

For anything about this formr instance itself (it's slow or down, you need the rights to create studies, something stopped working after an update), write to the people who run it. The Imprint should say who they are.

formr is open source, and several universities and labs run an instance of their own. Each decides who gets an account and when to update. Some are only meant for teaching or trying formr out, and some are full and take no new studies. Before you collect real data, ask whether this one suits your study and whether it's backed up. If it doesn't suit you, ask whether your university runs one, or run your own.

Your study or the instance?

If only one study is affected, it's usually the study, and you can fix it yourself. These tell you more:

  • When a module fails for a participant, formr emails you ("[formr] Run Notification") with the module, the participant's user code and the error. An R error, e.g. object 'big5' not found, is in your code: fix the module and check it with Test Run. An email saying that OpenCPU was unreachable, or that a request to it failed, is about the instance. More under When a module fails.
  • An email saying that formr could not run a step because of an error is about formr itself. Forward it to the people who run the instance, who find the details in the server's error log.
  • Under Logs in your study's menu, User Details shows each module a participant went through. A module that failed has its result in red, or in orange for some email problems such as no_recipient. Hover over a result to read its message.

It's probably the instance when things fail that don't depend on your study: the admin area, studies nobody changed, other people's studies. A "503" page comes from the instance. If a download of your data fails, try JSON first (see Getting your data out).

Reporting a problem

Write to the people who run this instance and say:

  • which version of formr the instance runs (see below),
  • your study's name, and the survey's if it's about a survey,
  • a participant's user code, if it's about one participant,
  • what you did, what you saw instead, and when,
  • the code on the error page, if you got one, and when it happened. They can look it up in the instance's logs.

If you've found a bug in formr itself, the Help tab says where to report it.

Which version you're on

The version is at the bottom right of every page in the admin area, after "formr". Click it, or open What's new, to see which version this instance runs, when it was updated (if the instance keeps a record of that) and what changed for study authors in each release. If something stopped working after an update, look there first: the releases it brought are marked "new since", with what you may have to check.

The version matters when you hit a bug. If this instance runs an old version, the bug may be fixed already. Tell the people who run the instance which version it runs when you report the bug, and ask whether a newer version fixes it. That beats a workaround in your study. If you cite formr in a paper, the update history on What's new also tells you which version ran while you collected your data.

Running your own instance

INSTALLATION.md in formr's source code says how to install formr on a server of your own, and what an instance for real studies needs. In short, you need:

  • a Linux server, because OpenCPU (which runs study authors' R code) needs Linux to keep that code contained,
  • a domain with HTTPS, ideally with a subdomain for each study, so that studies can't reach each other's pages,
  • an email account at a provider meant for automated mail,
  • someone who keeps it all updated, backed up and secure.

The developers' Docker setup (formr_dev_docker) is fine for trying formr on your own computer. Don't put it on the public web: its OpenCPU runs any R code it is sent, and neither the database nor the connection is encrypted. If nobody at your institution can set up an instance for real studies, the people who make formr offer this as a paid service (see INSTALLATION.md).

Moving a study to another instance

An export takes your study's modules, surveys and most settings along. Participants and their data stay behind.

  1. On the old instance, click Export on the study's Edit Run page, select all modules and leave Include survey items ticked. You get a JSON file.
  2. On the new instance, add your email account under Mail Accounts first, so the Email modules get one. Create the study (Create new Run), click Import on its Edit Run page and choose the file. Your surveys are created from it.
  3. Set what the file doesn't carry, e.g. your R Secrets' values, the study's title, publicness and app settings (Edit Run lists what it holds). Upload your files again and change the links that point to the old instance.

Participants' links still lead to the old instance. Download their data before you leave it (see Getting your data out), and let anyone who is midway through finish there, or move between waves.

Getting your data out

To download a survey's data, open the survey and pick a format under Export Results. If the download ends in an error page, pick JSON instead.

The formats are CSV, German CSV, TSV, XLS, XLSX and JSON. German CSV separates the columns with semicolons, which is what Excel expects when it runs in German. Each row holds one participant's answers to the survey, one column per item. If someone filled out the survey several times, e.g. every day of a diary, they get one row per time.

When a download fails

CSV, TSV, XLS and XLSX are built as a whole spreadsheet in the server's memory before the download starts. For a large study that takes more memory or time than the server allows, and you get an error page (usually "500 Fatal Error") instead of a file. JSON is written one row at a time, so it usually still works when the others don't. It's the first thing we suggest when someone reports a failed export. Download the JSON and convert it on your own computer. In R:

results <- jsonlite::fromJSON("mysurvey.json")
writexl::write_xlsx(results, "mysurvey.xlsx")

In Python, pandas.read_json("mysurvey.json") reads it too.

Straight into R

If you analyse your data in R, you can skip the downloads. The formr R package fetches the results of every survey in a study, joins them into one data frame and computes your scales (items such as extraversion1, extraversion2R and extraversion3 become extraversion). You need an API credential for this. The API tab explains how to get one and store it with formr_store_keys(). After that:

library(formr)
formr_api_authenticate(host = "https://api.researchmixtape.com")
results <- formr_api_results("my-study")

Your own test participants are left out unless you set remove_test_sessions = FALSE. So are real participants whose user code contains XXX, because the package takes every such code for a test: everyone you added under New Named User with a name (formr puts XXXXX into their user codes, and XXX before formr 2.0), and about 1 in 4,300 random codes. To keep them, set remove_test_sessions = FALSE and leave out your test users yourself:

results <- formr_api_results("my-study", remove_test_sessions = FALSE)
test <- formr_api_sessions("my-study", testing = TRUE, limit = 10000)
results <- results[!results$session %in% test$session, ]

The package (version 1.3.0) has more limits:

  • On v2, it computes no scales.
  • If your study has only one survey and nobody has passed a Shuffle, the package has to guess which survey the table is. For a v2 form, or a survey your study uses at more than one position, it can't. It warns and returns the table as it is, test users included.
  • If people fill out more than one survey several times, e.g. a morning and an evening diary, the joined data frame pairs every row of one with every row of the other, participant by participant, without a warning (14 mornings and 14 evenings give 196 rows). Use join = FALSE and combine the tables yourself.
The study's export is a different table

Export Run Data, in your study's menu in the admin, gives you a long table: one row for every item each time a participant was given its survey, with when it was shown and when it was answered. That's what you want for timing, or to see where people stopped. For the answers themselves, the survey exports are easier to work with. The long table, like the export on a survey's Detailed Results page, has these columns for the timing:

  • shown is when the item's page loaded, or when a showif revealed the item later. On a v2 form, it's when the item first came into view.
  • answered is when the answer was last changed, and saved when it reached formr. If there was no answer (e.g. to a note), answered is the same as shown.
  • shown_relative and answered_relative are milliseconds in the participant's browser, so they don't depend on the connection. In a classic survey, they count from when the page opened. On a v2 form, they count from the first time the participant was shown the item's page, also across visits in the same browser. So someone who comes back to a page the next day has a large answered_relative. Take answered minus shown, or only rows with a displaycount of 1.
  • displaycount is how often the item was displayed. A classic survey counts each time its page is sent to the browser, so a page that came back with an error counts again. A v2 form counts 1 when the item first comes into view, and 1 more each time its page (in the solo layout, the item) is shown again, also after a reload. An error doesn't count there, because the page isn't loaded again.

On v2, items of a page that a participant opened and left unanswered have shown and displaycount too. An item that never came into view has no displaycount and no shown_relative, even if a default value was stored with its page.

Two kinds of survey are left out of it. A survey whose results you've hidden in its settings has no export at all, so it isn't in the study's export either. And unlinked surveys are left out, because this table ties every answer to a participant.

Sending emails

When a study's emails don't go out, look at the mail account they're sent from first: 8 times out of 10 someone changed the password, or it expired, and nobody told you. Under Mail Accounts in the admin menu, enter the password again and save the account with the test ticked. If that doesn't help, read on.

Setting up a mail account

formr sends your study's emails through a mail account of yours. Under Mail Accounts, click Create New Account:

  • From (email) and From (name) are the sender participants see. Use an address that belongs to the mail server you send through.
  • SMTP Host and SMTP Port come from your provider or IT department, e.g. smtp.example.org and 587. Tick Use TLS for port 587. For port 465, untick it and formr uses SSL.
  • Username and Password are the login for the mail server. formr doesn't show the password again. To keep it when you edit the account, leave the field empty.
  • Leave Test E-mail account on save ticked. formr then sends a test email to the From address. If that fails, you see "Account Test Failed" with the error, and the account is marked not working instead of tested.

Each Email module sends through the account you pick under Account, or through your first one.

Your university's or institute's mail server often works. Ask IT whether it allows automated sending, and how many emails an hour. Gmail and Outlook usually do not work, because they prevent automated sending. Neither do mail systems that no longer accept a password from other programs. If you send many emails a day, a service made for automated email may suit you better. formr refuses a mail server whose name or address belongs to a local network, unless the people who run this instance allow it.

Replies go to the form's Reply-To address, or to From (email) if you leave it empty, so give one that someone reads.

When emails don't go out

Start under Mail Accounts. formr sends your study's emails only through an account that is marked tested. While it's untested (saved without a test) or not working, participants who reach an Email module that uses it wait there (error_email_account), and formr emails you about it once. They go on by themselves, within about ten minutes, once the account works. So save it again with the test ticked. formr also marks an account not working when it couldn't connect to its mail server for about 20 minutes. It then tries again every half hour for 24 hours, and the account works again as soon as the server answers. After that, test it yourself. The test's error "SMTP connect() failed" can also mean a refused password, so check that first. Next most likely, the mail server's certificate changed (ask IT). Then check host, port and Use TLS.

Then open the study's Emails log (under Logs in the study's menu) and hover over a status for details. In a study with an unlinked survey or one that hides its results, the recipients show as *** (why). Emails to participants you have deleted aren't listed. email_queued is waiting to go out, also while the mail server can't be reached. email_sent means the mail server accepted it, and the participant's provider decides the rest (see spam). error_email_not_sent means the server refused it. With the default settings, formr tries four times, about five minutes apart, and then says email_gave_up. It says so, too, when an email has waited for 24 hours, or for an hour because of the limits below, and doesn't send it any more. By then the participant has moved on, without the email. formr emails you about emails it couldn't send, at most once a day for each mail account, with the studies and positions they belong to.

An email that never got that far isn't in this log. Look the participant up under User Details: no_recipient means formr found no address, invalid_email that it wasn't one, error_email_account that the mail account is untested or not working, and error_send_eligible that this participant's study made one address 100 emails in a day, e.g. in a loop. The participant waits at the Email module, and formr tries again about every 10 minutes. formr also emails you about these (When a module fails). Its emails to you come from this formr instance's own address, so they arrive when your mail account is broken.

Other reasons:

  • Send e-mails only when cron is running is ticked. Participants who reach the Email right after a survey move on without it (email_skipped_user_active). The box is meant for emails after a Pause.
  • The study's Automated actions are off (General settings). Emails after a Pause then wait until the participant opens the study again.
  • The participant stopped your emails on their settings page (email_skipped_user_disabled).
  • Too many emails to one person. By default, formr sends one address at most one email a minute, two in 10 minutes, four an hour, 10 a day and 60 a week from the same sender, counting the emails already sent. Later ones wait in the queue for up to an hour while the participant moves on, and after that formr doesn't send them. Of two Emails right after each other, the second goes out a minute later.
  • Your mail server's own limits. Many servers refuse emails beyond so many an hour or a day.
  • The address can't receive email (e.g. name@gmail.con), or the people who run this instance have blocked it. formr skips it, and the participant moves on (error_email_guard_refused).
Emails in the spam folder

The participant's provider decides whether an email lands in the inbox, and avoiding the spam folder is more of an art than a science. What you can do:

  • Send through an account that logs in, from an address of the mail server's own domain, e.g. your university address through your university's server. Emails from an address the server doesn't belong to often fail the providers' checks.
  • Write plainly, with a subject that names your study and not much besides the link.
  • Use an address people recognise. In your first survey, ask them to add it to their contacts and to look in the spam folder for your first email.
  • Put {{settings_link}} in your emails. There, participants can stop your emails for a while or for good. Otherwise some mark them as spam, which can send your other emails there too.

The rest is up to the people who run the mail server: SPF, DKIM and DMARC, the records providers use to check that an email really comes from the domain it claims. You can't set those up in formr. If your emails keep landing in spam, forward one that did to your IT department. Its headers can show them where the problem is.

Who gets the email

The Recipient field of an Email module takes one of these:

  1. most recent reported address (the default): the address the participant last entered in an email item, in any survey of this study.
  2. An item, e.g. big5$email_address, for when participants give more than one address. The field suggests your email items, and you can type others, e.g. a calculate item. R is case-sensitive, so big5$Email is not big5$email.
  3. A fixed address in single quotes, e.g. 'study-team@example.org', to hear about each participant. Without the quotes, formr reads it as R code, which fails. The limits above apply to this address too (by default 10 emails a day at most). Emails beyond them wait for up to an hour and are not sent after that. Your participants don't wait. Your own formr address and the account's From address may get three a minute and 100 a day.
  4. R code that returns an address, e.g. paste0(intake$staff_id, "@example.org"). Only the first address counts, so use one Email module per recipient.

The module's Test button sends one email to you and shows which address each of a few participants would get (only whether it's a valid one, if your study hides its participants' addresses).

A participant without an address would wait at the Email module. If the address is optional, let them skip it:

  • Pos. 10. a survey called intake with an optional email item called email_address.
  • Pos. 20. a Skip Forward to position 60 if is.na(intake$email_address).
  • Pos. 30. a Pause until the next day.
  • Pos. 40. an Email to intake$email_address with {{login_link}} in its body.
  • Pos. 50. a survey called followup.
  • Pos. 60. a Stop Point.

What would happen? Participants who left the address empty go straight to the end. Everyone else gets an email the next day with a link back to their place in the study, and fills out the follow-up. The placeholders list the other links an email can hold.

Studies in progress

After an update to formr 2

Your studies, surveys and data stay as they are, and classic surveys keep running on the classic engine. Some fixes change what a running study does, so check these:

  1. Mail accounts. An Email module sends only through an account marked tested. With another one, participants wait at the module. Open Mail Accounts and save each account that isn't tested again with the test ticked (When emails don't go out).
  2. Time limits. finishing editing within does nothing while Start editing within is 0. A survey that relied on it alone no longer ends for participants who started it. Set an access window or an Inactivity Expiration (Time limits).
  3. External links with end using API ticked. They now hold participants until the other side makes its call, or until Expire after is over. If your service never calls back, untick the box or set Expire after (External link).
  4. Deletion dates. Before formr deletes results, it keeps them in an encrypted backup for 30 days, and the record of a study's emails stays that long too. If you promised deletion by a date, set Expires On 30 days earlier.
  5. Your next upload. Item names need 2 to 64 characters and start with a letter, a choice's name may appear only once in its list, and options that never worked are refused, e.g. a rating_button with words or a step of 0. A sheet that uploaded before may need a fix. Surveys already uploaded keep running.

What else is different:

  • Uploads. An upload that removes, renames or re-types an item stops once one real participant has answered it (before, it took more), until you type the survey's name. Through the API it needs confirm_deletion.
  • Emails. One over the limits for an address waits an hour at most and then isn't sent. Participants no longer wait for it. Replies go to the account's Reply-To. In a study with an unlinked survey or one that hides its results, Emails and Users show *** for addresses.
  • Moving participants in Users or through the API runs the module as formr does while they are away: a Waiting Time waits, and an Email set to cron only goes out. A move to a position without a module is refused.
  • Pauses. One whose relative to is FALSE is asked again every 10 minutes, also after a day.
  • Returning participants. Cookie/Session Lifetime 0 now means as long as this instance keeps a session, for participants who accepted cookies. It used to end with the browser. On shared computers, use ?_new_session=1 (When formr mixes them up).
  • User codes. New test users' and named users' codes hold XXXXX (XXX before).
  • v2 forms from a release candidate. The item display table's shown, answered and displaycount mean something else, mc_heading rows aren't shown, and three CSS classes have the sizes their names say.

What's new (Which version you're on) lists every release.

Changing a study while participants are in it

formr keeps the answers participants have given, and a change applies to everyone who reaches the changed part afterwards. The change that can cost you answers is removing, renaming or re-typing a survey item.

Before you change anything, download the data (see Getting your data out) and click Export on Edit Run with Include survey items ticked, so you have the study as it was. Then try the change with a test user: Test Run starts one at the beginning (Old Guinea Pigs lists the ones you have), and in Users you can send it on to the part you changed (see below).

To change a survey, upload its new item table under Import Items and leave the Delete Results Confirmation box empty.

  • New items, new labels and choice labels, a changed showif or value, an item made optional: all answers stay. Participants who haven't finished the survey get the new items, even if they're part-way through, and they get a changed showif from their next page on. Earlier entries have NA for a new item.
  • Removing or renaming an item takes its answers out of the survey's results, and changing its type (e.g. from number to select_one) can too. Once a real participant has answered the item (test users don't count), formr stops such an upload with "No permission to delete data", and names the items and how many participants answered them (never for a hidden survey, and for an unlinked one only if they're more than ten). If you type the survey's name in the box, formr goes ahead. It first saves the old results in a backup, which you can download for 30 days. The answers also stay in the export on the survey's Detailed Results page, with a removed item marked as deleted (an unlinked or hidden survey's Detailed Results show nothing). But they're gone from Export Results, the API and R.
  • Uploads through the API, e.g. formr_api_upload_survey() in R, are stopped in the same way (with a 409 that names the items), unless the call says confirm_deletion. Version 1.3.0 of the R package can't say it, so make such a change in the admin. Import on Edit Run is stopped too if the file would change items of a survey you already have in this way. It can't be confirmed there.

To reword a question, keep its name and change its label. For a study that runs over months, you have two options:

  1. Use the same survey in every wave. All waves are in one table, but every change applies to all later waves, and removing an item takes it out of the earlier waves' results too.
  2. Use a copy of the survey for a later wave (e.g. big5_w2), with the same item names. Changes to the copy stay in that wave, and you join the two in R, e.g. with dplyr::bind_rows(). If the items are likely to change, we'd make a copy.

On Edit Run:

  • A changed module (an Email's text, a Skip's condition, a Pause's time) applies to everyone who reaches it from then on. Participants already waiting at a Pause or Waiting Time keep the end time it gave them when they arrived. To give them the new one, send them to it again in Users. With wait this many minutes, the count then starts over.
  • A new module is reached by everyone who hasn't passed its position yet. Those who have never see it, unless a Skip Backward takes them back.
  • When you renumber modules and click Reorder, participants move along with their module. But Skip Forward, Skip Backward and Waiting Time point at position numbers, and those stay as they were, so check each one. After Reorder, formr names the ones whose target has moved. It can't know the positions your R code returns. A Skip that points at a position without a module stops participants there, and formr emails you.
  • Removing a module asks you to confirm once anyone has reached it. What participants did in it is kept, and a survey's answers stay under Surveys. Participants who were at the module go on to the next one (at their next visit, if automated actions are off).
  • The numbers next to each module count participants who are at it now (blue), timed out there (grey) or finished it (green), test users included. Look at them before you move or remove a module.

Lock keeps you from changing a module by accident between your edits.

Pos. 10. a survey called intake.
Pos. 20. a pause until 6 pm.
Pos. 30. an email inviting the participant to the diary, with {{login_link}}.
Pos. 40. a survey called diary, with Start editing within and Inactivity Expiration set.
Pos. 50. a skip backward to position 20, as long as nrow(diary) < 14.
Pos. 60. a stop point that thanks them.

Without those two settings, a participant who misses an evening stays at the diary (A diary study).

In the second week, you add an item sleep to the diary's sheet, rename stress to stress_today, and upload it. What would happen? The upload stops and names stress, because renaming it would take its answers out of the results. You put the old name back, change only the label, and upload again. Now it goes through without asking. Every diary entry from then on asks sleep, also the one a participant may be halfway through. The first week's entries have NA for sleep. The pause and the invitations go on as before.

Participants who don't move on

Participants stay at a module when the study's Automated actions are off, when the module waits for a participant who doesn't come back, or when it can't finish, e.g. because its R code fails or keeps returning FALSE. To find out which:

  1. Check Automated actions in the study's settings. While it's off, a Pause ends, an Email goes out and a survey times out only when the participant opens the study. I am panicking :-( turns it off, and so does formr when you reach your monthly compute limit, or once it has deleted the study's data on Expires On.
  2. Open Users and pick the module under Position to list everyone at it. Last Result says what happened there last. Red means an error, and orange a result with a message, which can be a problem too (point at it to read the message). Where it says "expires in", that's when formr next looks at the module, e.g. when a Pause ends. Participants who have been at the same survey, External link or Email for two days or more are highlighted. User Details shows a participant's whole path.
  3. Look for an email with the subject "[formr] Run Notification". formr sends one when a module fails.

The usual causes:

  • The participant opened a survey and didn't finish it. Without a time limit, a survey waits for them as long as it takes, and nothing after it happens. Set Start editing within and Inactivity Expiration (see Time limits). An External link waits the same way unless you set its Expire after.
  • A Pause's relative to returns FALSE. formr asks again every 10 minutes, so the pause ends up to 10 minutes after the condition came true. Return a date when you can: formr then waits for that moment, and your R code runs once instead of every 10 minutes.
  • R code fails or returns NA, often because of an answer the participant skipped. They wait at the module, and you get the email. formr picks up your fix at its next try, which can be hours away. To try at once, send them to that position again.
  • A Skip points at a position where no module is, e.g. after you renumbered.
  • An Email can't go out, e.g. because the participant gave no address, or because its mail account isn't tested or doesn't work. formr keeps trying, and you get the email.
  • An older Skip Forward is set to if user reacts, so it waits for the participant to open the study.

formr looks for participants who are due several times a minute. If Pauses end hours late for many participants at once while automated actions are on, the instance has a problem. Tell the people who run it, with a few user codes and the times.

To move a participant on by hand, open Users, pick a position in their row and click the hand next to it (Send this user to that position). The module they were at ends, recorded as moved by you rather than finished, and the one you picked starts. If no module is at that position, nothing changes and formr says so. Pick the next position to move them on, or the one they're at (e.g. their Pause) to start it over with its current settings. To move several, tick them and use Do with selected below the table. That skips participants who are already at the position you pick, so start a module over row by row.

formr runs the module you picked as it does while participants are away. A Pause or Waiting Time starts waiting, an Email goes out, and a survey or an External link waits for their next visit. A Stop Point ends their session at once. If you open the study as a participant (the spy icon), though, that counts as their visit. At a Waiting Time, it sends them to its move to position.

Pos. 10. a survey called intake, which asks for the date of the participant's exam (exam_date).
Pos. 20. a pause, relative to Sys.Date() > as.Date(intake$exam_date).
Pos. 30. an email inviting the participant to tell you how the exam went.
Pos. 40. a survey called after_exam.

What would happen? The pause returns FALSE until the day after the exam. formr asks every 10 minutes, so the invitation goes out within 10 minutes of midnight, when few people read their email. A participant who skipped exam_date gets NA and waits at the pause, and you get an email. With relative to set to as.Date(intake$exam_date) + 1 and wait until time to 10:00, the pause ends at 10 am on the day after the exam. Participants without a date still wait, so send them on by hand.

Personal data and deleting it

Ask for identifying data such as email addresses in a survey of its own, and unlink that survey or hide its results. If a participant asks you to delete their data, delete them in your study's Users list. When your study expires, formr deletes every participant's data in it.

Ask for consent in a short survey of its own at the start of your study, and send those who decline to a Stop Point of their own.

Pos. 10. a survey called consent: your information sheet in a note, a required mc item
called agree (1 = I agree, 2 = I do not agree) and a submit.
Pos. 20. a skip forward to position 50, if is.na(consent$agree) | consent$agree != 1.
Pos. 30. a survey called big5.
Pos. 40. a stop point that thanks participants.
Pos. 50. a stop point for those who declined.

What would happen? Everyone reads the information sheet. Those who agree go on to big5. Those who decline see the Stop Point at 50 and none of your questions. Their row in consent stays, with their answer and the time, so you can report how many declined. is.na() catches people for whom the survey ended without an answer, e.g. after a time limit.

  • Your privacy policy goes under Settings → Privacy. A new study's footer links to it on every page.
  • Tell participants how to withdraw. Their settings page (in the footer, or {{settings_link}}) shows their user code, which they can send you (Deleting one participant's data).
  • A survey that was opened has a row in its results, also when nothing was answered. So ask nothing else in consent.
  • Import on Edit Run has this pattern ready as Data_Quality, with an information sheet to replace. It brings a bot-detection study along: delete what you don't need.

formr gives you the mechanics. Whether your information sheet and your wording are enough is for your ethics board and your data protection officer to say.

Identifying data

Put what identifies people (email addresses, phone numbers, names, payment details) into a survey that asks for nothing else. Before anyone fills it out, turn on one of two settings of that survey:

  1. Survey Unlinking, if you need to read the data yourself, e.g. to pay participants. You can download it, but in random order and without user codes, and only once it has more than ten results from real participants.
  2. Disable Results Display, if only your study needs the data, e.g. addresses for reminders. You can't see or download it at all.

Neither can be turned off again. With either, your study's Emails page and its list of users no longer show you participants' addresses. Inside formr, the data stays linked to the participant, which is how an Email module knows whom to invite. The settings keep you from linking it by accident. They can't stop someone who sets out to.

If your study works as an app on participants' phones, you may not need addresses at all: push notifications reach them without one.

A diary study that pays its participants could look like this:

Pos. 10. a survey called contact, with Disable Results Display on, which asks for the
participant's email address.
Pos. 20. a survey called diary with the day's questions on drinking and mood, with
Start editing within and Inactivity Expiration set.
Pos. 30. a pause with wait until time 19:00 and next_day() in relative to.
Pos. 40. an email to the address from contact, inviting them back with {{login_link}}.
Pos. 50. a skip backward to position 20, as long as nrow(diary) < 21.
Pos. 60. a survey called payment, unlinked, which asks where they want to be paid.
Pos. 70. a stop point that thanks them.

Without those two settings, a participant who misses an evening stays at the diary (A diary study).

What would happen? Participants give their address once and fill out the diary every evening for three weeks. You never see the addresses in contact's results. At the end, you download payment and pay everyone on the list. (Unlinked results only show once more than ten real participants have filled out payment, so a smaller study needs another way to pay.) You analyse diary with its user codes, and nothing you download says whose diary is whose. Once everyone is paid, click Delete Results in the menus of contact and payment (this deletes their results in every study that uses these surveys). formr keeps the deleted results for another 30 days in encrypted backups. Then payment's are gone. The addresses from contact are also in formr's record of the emails your study sent, with each email's text and the participant's login link. Your study's Emails page doesn't show these addresses, but the record stays until you delete the participants or your study expires, and then for 30 more days. The diary stays until your study expires.

Deleting one participant's data

Find the participant's user code in your study's Users list and click the bin in their row.

  1. Ask them for their user code. Their settings page for your study shows it under Data Deletion Request and tells them to send it to you. A new study's footer links to that page, and {{settings_link}} puts it in an email (see Placeholders).
  2. In the admin, open your study, click Users, paste the code into the search box and search.
  3. Click the bin in their row and confirm with Delete.

That deletes where they were in your study and their answers to all of its surveys, unlinked and hidden ones included. The files they uploaded go in formr's nightly cleanup. No backup is made, and you can't undo it. What stays:

  • The record of the emails sent to them (address, subject and text, including any login link with their user code) is kept for 30 more days. You don't see it any more, and formr counts it against the limits on emails to one address. Emails that were still waiting to go out to them aren't sent.
  • A log that formr keeps against misuse holds the address of each email, for 90 days by default.
  • Result backups made before you deleted them hold their answers until those backups go, at most 30 days later, and so do the instance's own backups. Ask the people who run this instance about those.

Delete their data from the copies you downloaded, too.

You need the user code because the results of an unlinked or hidden survey don't show it. That's what those settings are for. In a survey that is neither, the session column of its results holds the user code.

To delete only part, e.g. a diary entry filled out by mistake, open User Details and click that entry's bin. formr warns you, because it deletes the entry's answers. If the participant is still taking part, a loop that counts entries (nrow(diary) < 21) gives them one more day. You can't delete a single answer, and neither your study's R code nor the API can delete a participant.

When your study expires

On the date in Expires On, formr deletes the data of every participant in your study, after reminding you several times (how that works). That includes the answers you analyse, so pick a date by which you'll have downloaded and checked everything (see Getting your data out), and delete identifying data earlier, as in the example.

What stays after that date, and for how long:

  • Before it deletes, formr saves the surveys' results in encrypted backups (as it does for Empty Run and Delete Results). You can download them for 30 days, and then formr deletes them. A survey that had only test users' rows in this study gets none.
  • The record of the emails your study sent, with each address, subject and text, is kept for 30 days. You don't see it any more, and formr counts it against the limits on emails to one address. Emails that were still waiting to go out aren't sent.
  • A log that formr keeps against misuse holds the address of each email, for 90 days by default.
  • The instance's own backups, for as long as the people who run it keep them.

If you promised participants deletion by a certain date, set Expires On early enough, and ask the people who run this instance about their backups.

Returning participants

Participants come back to your study through their own link, which carries their user code ({{login_link}} in your emails). In the browser they used before, formr also remembers them for a while, so your study's ordinary link takes them back to where they stopped.

Coming back
  • In the same browser, formr remembers them for as long as your study's Cookie/Session Lifetime says (see Study settings), counted from their last visit. A new study has 0, which means as long as the instance keeps a session (a year by default). The lifetime only counts for participants who allowed functional cookies, which formr asks for in a bar at the bottom of the page. Everyone else is forgotten when they close their browser.
  • With their own link, they get back from any browser on any device. {{login_link}} in an Email or on a Stop Point gives each participant theirs (see Placeholders). Whoever opens the link carries on as that participant, so ask people not to pass it on.
  • After they log out ({{logout_link}}, or the button on their settings page), the browser forgets them. Their answers stay saved, and their own link brings them back.
Phones and apps

To move a participant from their computer to their phone, a request_phone item shows them a QR code of their own link. If your study is an app on their home screen, it opens with the user code of whoever added it, and generating the manifest sets the lifetime to at least a year. If the phone forgets them anyway, the app asks for their latest email link or their code, which their settings page ({{settings_link}}) shows.

When formr doesn't recognise them

Usually they didn't allow functional cookies, so the browser forgot them when it closed. Other causes are a lifetime that is too short, another browser or device, a private window, or deleted cookies. A study shown in a frame on another website forgets its participants after the first page, because browsers don't keep formr's cookie there. Link to your study instead.

What helps:

  1. Send the login link wherever you ask people to come back: in invitations and reminders, and on the last page of each session. It works whatever their browser remembers.
  2. Put a request_cookie item on your first page, so participants allow the cookie that the lifetime needs.
  3. If your study sets a Cookie/Session Lifetime, make it longer than the longest break between two visits.
When formr mixes them up

A browser remembers one participant, so the next person at that browser carries on in their place. That happens in the lab, when people take part one after another on one computer. It also happens when someone goes through the same study again on purpose, e.g. a sign-up study for course credit that students pass through after each of several experiments. The second time, they land where they stopped, often at the end. You have the following options:

  1. Give out your study's link with ?_new_session=1 added. Every visit then starts as a new participant (see Participant links tab). Someone who closes the tab and opens that link again starts over, though, so don't use it in emails.
  2. Put an External link module whose address is {{logout_url}} after your last survey, and a Stop Point after it. Participants are logged out without a click, but they end on formr's "Session Ended" page instead of your last page.
  3. Put {{logout_link}} on your last page. Your page stays, but it only helps when people click it.

A logout link works only when the participant opens it, not hidden in a frame or an image. Two different studies keep their participants apart: each remembers its own and gives them a user code of its own. That holds where each study has an address of its own (yourstudy.example.org). Where all studies are under one address (example.org/yourstudy), a participant whose browser still has a cookie for that whole address (from a formr version before 2.0, or set by a study's script) can get the same user code in each study they then open by its plain link.

Codes of your own

You can make user codes yourself, e.g. to send each person on a list a link with ?code= and their code. By default, a code is exactly 64 characters long and made of letters, digits, -, _ and ~ (the people who run this instance can change that rule).

  • A code formr doesn't know yet starts a new participant with that code, as long as your study's publicness lets newcomers in (People who have the link can access or higher).
  • A code that breaks the rule gets "Invalid user code. Please contact the study administrator." The visitor carries on as whoever the browser remembers, or as a new participant with a code from formr.

You can also add participants before they start. New Named User in your study's menu adds one at a time, and formr makes the code. The API adds many at once with codes you choose, or one with a code from formr (POST /v1/runs/{name}/sessions).

Don't call a URL parameter of your own code, e.g. for a panel ID, because formr reads it as a user code. Give it another name (?pid=…) and save it with a get item.

Stopping people from taking part twice

formr has no check of its own for repeat participants. Someone who opens your link again in the same browser lands where they stopped, but in another browser they start over as someone new. You have the following options:

  1. Let your panel do it. Save the panel's ID with a get item, e.g. get PROLIFIC_PID. Panels know their members, usually let each take part in a study once and can keep out people from your earlier studies. This only covers people who come through the panel.
  2. Invite people with a link each. Add every participant beforehand (see above), set your study's publicness to You and people who already have an access code can access (no new users can enrol) and send each their own link. Nobody without a link gets in, and someone who opens theirs twice carries on where they were. You need everyone's contact details in advance.
  3. Check an ID against earlier participants in R. This works for anything people can't easily change, e.g. a panel ID or an email address, and it only catches that ID (someone with two email addresses gets in twice).

For option 3 you need the API, because inside your study a survey's data frame only holds the current participant's answers. Inside your study the API needs no credential, but the study owner's account needs API access (admin level 2, see Using the API in R). Without it, the code below fails and every participant waits at Pos. 20. Keep the ID in a survey that is neither unlinked nor hidden. The API gives an unlinked survey's answers without user codes, and a hidden one's not at all.

  • Pos. 10. a survey called intake with a get PROLIFIC_PID item named prolific_pid.
  • Pos. 20. a Skip Forward with the code below. If the ID is new, it skips forward to Pos. 40.
  • Pos. 30. a Stop Point: "You've already taken part in this study. Thank you!"
  • Pos. 40. your real survey.
formr_api_authenticate()
earlier <- formr_api_fetch_results(surveys = "intake", item_names = "prolific_pid")
if (!is.data.frame(earlier)) earlier <- earlier$intake # a study with a Shuffle gets a list
earlier <- earlier[earlier$session != user_id, ]
!(intake$prolific_pid %in% earlier$prolific_pid)

What would happen? A participant fills out intake. At Pos. 20, formr fetches every panel ID given in intake so far, minus the participant's own row (user_id is their user code). If their ID is new, they skip on to your survey. If it's there already, they stop at Pos. 30. Your test runs count as earlier participants too, so test with a new ID each time.

Recruiting through a panel (Prolific, MTurk and others)

Give the panel your study's link with the panel's ID parameter in it, save the ID with a get item on your study's first page, and send participants back to the panel when they're done. The ID lets you match your data to the panel's records, e.g. to pay people.

Pos. 10. a survey called intake. Its first row is a get PROLIFIC_PID item called prolific_pid,
followed by your consent form.
Pos. 20. a survey called main.
Pos. 30. an External link whose address is the completion link Prolific gave you.
Pos. 40. a Stop Point that thanks participants and shows the completion code.

What would happen? A participant clicks your study on Prolific and arrives at https://study.researchmixtape.com/yourstudy/?PROLIFIC_PID=5f3e9a. formr saves the ID as soon as the first page of intake opens, and you'll find it in the prolific_pid column. After main, formr sends them back to Prolific, which records that they finished. If they open your study again, they see the Stop Point.

The link and the ID

Panels can add each participant's ID to the link they open, under a parameter name of their own. Prolific's is PROLIFIC_PID. For other panels, their help pages say which name they use. A get item saves the parameter it names, so get PROLIFIC_PID saves Prolific's. If a panel sends several parameters, give each one you need a get item of its own.

  • Put the get items in your first survey, before its first submit. The parameter is only in the link participants opened, so a get item on a later page or in a later survey finds nothing.
  • Don't call the parameter code. formr reads code as the participant's user code, and your participants would see "Invalid user code" (see Codes of your own).
  • A get item can only read a parameter whose name is made of letters, digits and underscores.
  • A get item is required unless you put * in its optional column. While it's required, people who open your study without the parameter are stopped with an error message. That keeps out people who didn't come through the panel. It stops you too when you test, so add the parameter to your test's address, e.g. &PROLIFIC_PID=test1.
Sending them back

The panel needs to know who finished. You have the following options:

  1. Send them back by link. Put an External link module after your last survey, with the completion link the panel gives you as its address (Prolific's ends in ?cc= and your study's completion code). formr sends participants there as soon as they reach it, and the panel records them as finished.
  2. Show a completion code on your Stop Point, which participants copy into the panel's form. A code that's the same for everyone can be passed on. For a code of each participant's own, write `r stringr::str_sub(user_id, -10)` on the Stop Point (the last ten characters of their user code), and before you pay, check the codes against the session column of your data.

Some panels want their ID in the link back. Then write R as the External link's address, and let it build the link:

paste0("https://panel.example.org/complete?id=", intake$panel_id)

If the R code returns an address, formr sends participants there. If the panel wants a call from your study instead, make the call in the R code (e.g. with httr::GET()) and return FALSE or NULL. The study then moves on without sending anyone away. The External link module has the details.

Put a Stop Point after the External link. Participants who open your study again later land there, so show the completion code on it too.

People who come back or come twice

People who open the panel's link again carry on where they were only if their browser still remembers them. If it doesn't, e.g. because they didn't allow functional cookies and closed it, or because they switched devices, formr takes them for a new participant. You'll then find two rows with the same panel ID, one of them unfinished. Put a request_cookie item on your first page, and don't set a short Cookie/Session Lifetime (see When formr doesn't recognise them). If your study has several sessions, e.g. a diary, participants need their own link to come back, such as {{login_link}} in an email (Returning participants).

Panels usually let each member take part in a study once. Someone can still open your link again outside the panel, though. To catch them, check the panel ID against everyone who took part before, as shown under Stopping people from taking part twice. That check also stops someone whose browser forgot them halfway through, so ask for the cookie as well.

Showing items only to some participants

Write a condition into the item's showif column, and formr shows the item only when it's true. demographics$smoker == 1 shows it to the people who said they smoke. In a classic survey, you write the condition in R. In a v2 form, you write it in JavaScript (see below).

Answers from earlier surveys and pages

formr checks a showif when the page opens, with the answers given so far.

  • For an item of another survey, name the survey too: demographics$smoker == 1. If participants filled that survey out several times, e.g. a diary, the item holds every answer, oldest first, and formr would go by the first. Say which one you mean, e.g. last(diary$mood) < 3 for the latest or any(diary$mood < 3) for any of them.
  • For an item on an earlier page of the same survey, its name is enough: smoker == 1. In a diary, mood is today's answer and diary$mood all of them.

An item whose showif is false stays hidden, and its column is empty (NA).

Items on the same page

If your showif uses an answer from the same page, write a plain comparison such as smoker == 1. formr first checks the showif in R as the page opens, when that answer is still missing (NA). The comparison is NA too, so the item is put on the page hidden and appears as soon as participants give the answer. For that, formr translates your showif into JavaScript, which the browser runs. This holds with and without Custom Paging.

What fails on the same page:

  • !is.na(smoker) & smoker == 1 and isTRUE(smoker == 1). R can already decide. They are FALSE, so the item is left off the page and the browser never gets a say.
  • is.na(smoker) | smoker == 1. It is TRUE, and the item stays shown (see below).
  • %in%, ifelse() and whatever else the translation doesn't know. It knows comparisons, &, |, !, TRUE, FALSE, is.na() and the helpers for multiple choices below. With anything else the item stays hidden, so write pet == 1 | pet == 2, not pet %in% c(1, 2).

If only the browser should decide, end the showif with //js_only (see below).

The translation leaves & and | as they are. Between comparisons, they do what they do in R. Between numbers, JavaScript compares them bit by bit, so mood & sleep is false for the answers 1 and 2, where R says TRUE. Write mood > 0 & sleep > 0. JavaScript also always evaluates both sides, so if one side uses an item that isn't on the page, the whole showif fails in the browser, and the item stays as it was when the page opened.

The browser only knows the answers on the page. So if your showif combines an earlier survey with an answer on this page, the item stays hidden. Bring the earlier answer onto the page with a hidden item and use that in the showif:

  • a hidden item mom_alive with the value demographics$mom_alive,
  • an item conflict ("Did you have a conflict with someone today?", 1 = yes),
  • an item conflict_mom with the showif mom_alive == 1 & conflict == 1.

The hidden item has to be on the same page as the showif that uses it. Participants can read its value in the page's source, so don't bring anything over they shouldn't see.

If a showif is already true when the page opens, its item can stay shown, whatever participants answer on that page. To show an item at first and hide it after a certain answer, end the showif with //js_only, e.g. is.na(can_answer) | can_answer == 1 //js_only. Then only the browser decides. Use //js_only too when the answer it depends on has a value that R computes, e.g. sticky. Otherwise R decides with that value as the page opens, and the item stays shown or is left off the page, whatever participants answer.

Multiple choices

mc_multiple and select_multiple items save the ticked choices as text, separated by a comma and a space, e.g. 1, 4, 7. So pets == 4 is only true if 4 is the only choice ticked. Instead, write:

  • pets %contains_word% "4": 4 is among the ticked choices.
  • pets %contains_word% "4" & pets %contains_word% "7": both are.
  • !(pets %contains_word% "4"): 4 isn't. Keep the parentheses, because the browser reads ! differently from R.
  • pets == "4, 7": these two and no others.

%contains% looks for any part of the text, so pets %contains% "4" would also be true for 14. Both helpers come with formr's R package (R Helpers). On the same page, put the choice in quotes ("4"), or the translation into JavaScript fails.

Unanswered items

A skipped answer from an earlier page or survey is NA in R, and so is any comparison with it. formr hides an item whose showif comes out NA. So demographics$smoker != 1 hides the item from people who skipped smoker, too. If they should see it, say so: is.na(demographics$smoker) | demographics$smoker != 1. If an item must only appear once something is answered, write !is.na(demographics$smoker). This is for answers from earlier pages. On the same page, !is.na(smoker) leaves the item off the page. A plain smoker == 1 is enough there.

On v2

On v2, you write showifs in JavaScript. They run in the browser whenever an answer changes, so items on the same page need nothing special. The helpers have JavaScript names, e.g. contains(pets, 4) for multiple choices. An unanswered item doesn't hide what depends on it, as NA does in R: smoker != 1 and mood < 3 are true before the participant has answered. If the item should wait for the answer, write answered(smoker) && smoker != 1 (Unanswered items). Answers from other surveys aren't on the page there either, so bring them in with a hidden item as above (Bridging R into a showif). The Form (v2) tab lists the other translations.

Adapting question texts

If you want to word a question differently for different participants, put R into its label instead of writing two items with opposite showifs. With partner_gender from a survey called demographics (1 = man, 2 = woman, 3 = another gender), the label could be:

How long have you known your `r c("boyfriend", "girlfriend", "partner")[demographics$partner_gender]`?

formr fills in the label when the page opens, so the answer it uses must come from an earlier survey or an earlier page of this one. Choice labels can hold R in the same way. A skipped partner_gender would show as "NA, NA, NA", so make it required, or say what to show then. If you need the word in many labels, define it once on your study's R Functions tab:

partner_word <- function(gender) {
  ifelse(is.na(gender), "partner", c("boyfriend", "girlfriend", "partner")[gender])
}

Then write `r partner_word(demographics$partner_gender)` wherever you need it. Knit R & Markdown has more examples.

A diary study, step by step

A diary study is a loop. A Pause waits until the evening, an Email invites the participant, the diary survey waits a few hours for them, and a Skip Backward sends them back to the Pause until they've had enough evenings. Here's a two-week evening diary with a reminder:

  • Pos. 10. a survey called intake, with the consent form and an email item for the participant's address.
  • Pos. 20. a Pause with wait until time 19:00. Its Text to show while waiting says "Thank you! We'll send you the link to the next diary at 7 pm."
  • Pos. 30. an Email that invites the participant to today's diary, with {{login_link}}.
  • Pos. 40. a Waiting Time that waits 120 minutes. Participants who show up before then move to position 60.
  • Pos. 50. an Email that reminds them, again with {{login_link}}.
  • Pos. 60. a survey called diary, with Start editing within 120 and Inactivity Expiration 30 in its settings.
  • Pos. 70. a Skip Backward to position 20, as long as nrow(diary) < 14.
  • Pos. 80. a Stop Point that thanks them.

What would happen? A participant fills out intake at lunchtime and waits at the Pause. At 7 pm, they get the invitation. If they open it before 9 pm, they go straight to the diary. If not, they get the reminder at 9 pm, and the diary waits for them until 11 pm. Someone who starts the diary and then leaves it alone for half an hour is moved on as well. Filled out or not, the Skip Backward sends them back to the Pause, which now lasts until 7 pm the next day. After 14 evenings, they reach the Stop Point. Someone who fills out intake after 7 pm gets their first invitation the next evening.

You need the diary's time limits to keep the loop going. Without them, a participant who misses one evening stays at the diary, and no further invitation goes out. Leave the study's Automated actions on, too (General settings), or the Pause ends and the emails go out only when participants open the study.

To start everyone on the evening after they enrol, even those who enrol in the morning, put next_day() in the Pause's relative to. The Pause then lasts until 7 pm on the day after the participant reached it. Someone who finishes a diary after midnight skips the next evening, though.

To start from a ready-made loop, click Import on Edit Run and choose Basic_Diary (building blocks). Sending emails explains the mail account the invitations go out from. To invite participants with push notifications instead, see Sending the notifications, which builds the same loop. Before you change the diary while it runs, e.g. to add an item in the second week, read Changing a study while participants are in it.

Reminders

The Waiting Time at Pos. 40 sends the reminder only to those who need it. It counts its 120 minutes from the invitation. Participants who open the study in that time go to position 60, the diary, and never get the reminder. Everyone else carries on with the next position when the time is up, which is the reminder.

  • The diary's Start editing within counts from when the diary opened for the participant. For those who got the reminder, that's 9 pm, so they have until 11 pm.
  • Older guides use a Skip Forward set to if user reacts for this. New Skip Forwards don't have that option, and a Waiting Time does the same.
  • By default, formr sends one address at most 10 emails a day and 60 a week (When emails don't go out). An invitation and a reminder each evening fit easily. Several prompts a day, each with a reminder, don't, so use push notifications for those.
Counting the days

nrow(diary) counts the evenings on which the diary opened for the participant, filled out or missed. formr adds a row to the diary's results when it opens, and that row's ended stays empty if the participant doesn't finish. So the loop above ends after 14 evenings, however many diaries the participant filled out.

If you need 14 filled-out diaries instead, use sum(!is.na(diary$ended)) < 14 & nrow(diary) < 21 as the condition. Participants then get up to 21 evenings for their 14 diaries. Without the second part, someone who stops answering would get an invitation every evening, for ever.

You can use the same R in the diary itself, because today's row is there as soon as the page opens. A note with the label "This is day `r nrow(diary)` of 14." tells participants how far along they are. last(diary$mood) is the last mood they reported, because formr's last() skips missing answers.

Several prompts a day

Experience sampling is the same loop, run several times a day. The Pause computes when the next prompt is due, and the survey gives participants only a short time to answer. Here are five prompts a day or so, at random times between 9:00 and 21:00, for a week:

  • Pos. 10. a survey called intake, which asks participants to install the study and allow notifications (Making your study an app).
  • Pos. 20. a Pause with the R code below in relative to and nothing in its other fields.
  • Pos. 30. a Push Notification with the message "A few quick questions", Priority High and Time to Live 1800.
  • Pos. 40. a survey called esm, with Start editing within 30 and Inactivity Expiration 10.
  • Pos. 50. a Skip Backward to position 20, as long as nrow(esm) < 35.
  • Pos. 60. a Stop Point that thanks them.

The Pause's relative to:

library(lubridate)
prompt <- now(tzone = "Europe/Berlin") + minutes(sample(90:180, 1))
if (hour(prompt) >= 21) prompt <- update(prompt + days(1), hour = 9, minute = sample(0:59, 1))
if (hour(prompt) < 9) prompt <- update(prompt, hour = 9, minute = sample(0:59, 1))
format(prompt, "%Y-%m-%dT%H:%M:%S%z")

The esm sheet is short, so that it takes a minute:

typenamelabelchoice1choice2
rating_button 1,7,1moodHow do you feel right now? (very bad to very good)
mc_buttonaloneAre you alone?yesno
textactivityWhat are you doing?
submitdoneSend

What would happen? A participant finishes intake at 10:00. The Pause draws a time 90 to 180 minutes later, say 12:10, and formr sends the notification then. They have until 12:40 to start esm. Answered or missed, the Skip Backward sends them back to the Pause, which draws the next time. A time after 21:00 becomes one between 9:00 and 10:00 the next morning. After 35 prompts, about a week, they reach the Stop Point.

What goes wrong most often:

  • The Pause has to return a time. It is computed once, when the participant reaches the Pause. Code that returns TRUE or FALSE is run again every 10 minutes, so a sample() in it draws a new number each time.
  • Without the two time limits, the loop stops at the first prompt a participant misses.
  • nrow(esm) counts prompts, answered or missed (Counting the days).
  • With emails instead of notifications, mind the limits: one address gets at most four emails an hour and 10 a day. This schedule fits, and a reminder after each prompt would not.
  • Import offers this loop with emails as Experience_sampling.

Peer ratings: inviting others to rate a participant

Raters go through a study of their own. Your participants get a link to it that carries the last ten characters of their user code, and a get item in the raters' survey saves these. With them, you can join each rating to the participant's own answers.

Your participants' study, here called friendship:

  • Pos. 10. a survey called self, in which participants describe themselves and give their email address.
  • Pos. 20. an Email to the participant with the link for their raters (below), so they have it later.
  • Pos. 30. a Stop Point that shows the same link and asks them to send it to two friends.

The link, in the Email's body and in the Stop Point's text:

<https://study.researchmixtape.com/friendship-peers/?_new_session=1&target=`r stringr::str_sub(.formr$login_code, -10)`>

.formr$login_code is the participant's user code, and str_sub() keeps its last ten characters. Version 1.4.0 of the formr package adds `r login_code(10)` for this. Keep the angle brackets, so that the whole address becomes the link.

The raters' study, friendship-peers, with its publicness set to People who have the link can access:

  • Pos. 10. a survey called peer. Its first row is an item of type get target called target, and the rating items follow.
  • Pos. 20. a Stop Point that thanks them.

What would happen? A participant describes themselves, gets the email and sends the link to two friends. Each friend who opens it starts friendship-peers as a new participant, and target saves the end of the participant's user code as the page opens. You get one row in peer for each rating, and several rows can have the same target.

Joining the ratings

Download self and peer (see Getting your data out). In both, session holds the user code of whoever filled out the row, so in peer it's the rater's. The last ten characters of the participant's code are in target. In R:

self$target <- stringr::str_sub(self$session, -10)
ratings <- merge(peer, self, by = "target", suffixes = c("_peer", "_self"))

Each row of ratings holds one rating next to the participant's own answers. If you give the items the same names in both surveys, they come out as e.g. extraversion_peer and extraversion_self. This needs the user codes in self, so don't turn on Survey Unlinking there.

Raters on one device

A browser remembers one participant per study. Without _new_session=1, a second friend on the same computer would carry on where the first stopped, and someone who rates two participants would land at the end of their first rating, so the second would never be saved. With it, every visit starts a new rater (see Participant links). The catch: a rater who closes the page halfway and opens the link again starts over, and you get an unfinished row as well.

Call your parameter anything but formr's own. code is where formr puts the rater's own user code, and _new_session is gone by the time the survey opens, so a get item can't read either. Keep the get item on the survey's first page, because it saves what's in the address when that page opens.

Reaching the raters

You have the following options:

  1. Participants pass the link on, as above. They reach their friends however they like, and you collect nobody's address. You only know who rated from what you ask in peer.
  2. Participants enter their friends' addresses in self, and your study emails them: one Email module per friend, with a recipient such as self$friend1_email and the link in its body. You can remind raters this way. But you hold the addresses of people who haven't agreed to take part, which some ethics boards and some participants won't like. If the friends' addresses are email items, give the participant's own Email their item as its recipient, e.g. self$email. The default, most recent reported address, could pick a friend's address instead.
The user code in the link

Whoever has a participant's whole user code can carry on in your study as that participant (see Returning participants), so don't give it to the raters. The last ten characters are enough to join the ratings, and nobody can log in with them. Don't use the first ten: the codes of test users, and of participants you added under New Named User, begin with a name. If you make user codes yourself, see to it that their last ten characters differ.

Using other participants' data in your study

Your study's R code can count everyone in your study with .formr$nr_of_participants, and read everyone's answers once it calls formr_api_authenticate(). With that, a study can stop at a quota, balance its groups, compare each participant with everyone so far, or wait until enough people are there. It can't read the answers to a survey whose results you've hidden (Disable Results Display): the API gives none. An unlinked survey's come without user codes, in random order, and only once it has more than ten results from real participants (before that, only your test users').

.formr$nr_of_participants needs no API. It counts every user code in your study: test users, people who left after the first page, people you added beforehand, and the current participant.

For anything more, your account needs API access (admin level 2). Accounts that can create studies get level 1, so ask the people who run this instance for API access. With it, start your code with formr_api_authenticate(), without arguments. Then:

  • formr_api_results(surveys = "intake", remove_test_sessions = FALSE) gives everyone's answers to the survey intake, a row for each time someone was given it. If you ask for more than one survey, or once someone has passed a Shuffle in your study, the columns get the survey's name at the end (condition_intake).
  • formr_api_sessions(.formr$run_name, limit = 10000) lists the people in your study, newest first, with their position, when they ended the study (reached a Stop Point) and whether they are test users (testing). 10,000 is the most it gives at once.

formr_api_results() also computes your scales and leaves out test users' answers. But version 1.3.0 of formr's R package can't always tell which survey a table is, and then returns it as it is, test users included (Straight into R says when). So ask it to keep everyone and leave test users out yourself:

everyone <- formr_api_results(surveys = "intake", remove_test_sessions = FALSE)
test <- formr_api_sessions(.formr$run_name, testing = TRUE, limit = 10000)
everyone <- everyone[!everyone$session %in% test$session, ]

formr gives that code a token of the study owner's account, for this study only and for 180 seconds. It can read the study's data and move participants on, but it can't change the study's modules, settings or surveys. Write formr_api_authenticate() in the code that uses the data (e.g. a Skip Forward's condition, an item's value or a feedback text), or in a function in your R Functions that this code calls. Without API access, R stops with "No credentials found". Using the API in R has the details.

Each call reads your study's data afresh, so a page that uses it takes a little longer to load (formr_api_results() makes three requests). And two participants who arrive at the same moment see the same numbers, so the counts below can be off by one or two.

Quotas

To stop letting people in once 300 have finished, check how many have reached the end before a newcomer starts the main part.

  • Pos. 10. a survey called demographics.
  • Pos. 20. a Skip Forward with the condition below. If it's true, it skips forward to Pos. 40.
  • Pos. 30. a Stop Point: "Thank you for your interest. We already have all the participants we need."
  • Pos. 40. a survey called questionnaire.
  • Pos. 50. a Stop Point that thanks participants.
formr_api_authenticate()
done <- formr_api_sessions(.formr$run_name, active = FALSE, testing = FALSE, limit = 10000)
sum(done$position == 50) < 300

What would happen? Everyone who fills out demographics is checked at Pos. 20. As long as fewer than 300 real participants have reached the end at Pos. 50, they go on to the questionnaire. After that, newcomers see the Stop Point at Pos. 30. People who are already in the questionnaire can still finish, so you'll end up with a few more than 300. If you pay per participant, set the number a little lower.

For a quota per group, e.g. 150 women and 150 men, count only those who finished and gave the same answer as the current participant:

formr_api_authenticate()
done <- formr_api_sessions(.formr$run_name, active = FALSE, testing = FALSE, limit = 10000)
everyone <- formr_api_results(surveys = "demographics", remove_test_sessions = FALSE)
finished <- everyone[everyone$session %in% done$session[done$position == 50], ]
sum(finished$gender == demographics$gender, na.rm = TRUE) < 150

If a cap on all user codes in your study is enough (test users count too), you don't need the API: use .formr$nr_of_participants <= 300 as the condition. To close the study by hand, set its Publicness to You and people who already have an access code can access (no new users can enrol). Newcomers then see your service message, and people who started can finish. Your study's R code can't do that itself, because its token can't change settings.

Balanced groups

To keep your groups equal in size, give each newcomer the group that has the fewest people so far. A Shuffle draws each group at random instead, so in a small study the groups can end up quite unequal.

  • Pos. 10. a survey called intake. Its last row, after the last submit button, is a calculate item called condition with the code below as its value.
  • Pos. 20. a Skip Forward which checks intake$condition == "training". If it's true, it skips forward to Pos. 50.
  • Pos. 30. a survey called control_task.
  • Pos. 40. a Skip Forward which checks TRUE, so it always skips forward to Pos. 60.
  • Pos. 50. a survey called training_task.
  • Pos. 60. a Stop Point.
formr_api_authenticate()
intake_all <- formr_api_results(surveys = "intake", remove_test_sessions = FALSE)
test <- formr_api_sessions(.formr$run_name, testing = TRUE, limit = 10000)
intake_all <- intake_all[!intake_all$session %in% test$session, ]
n <- table(factor(intake_all$condition, levels = c("control", "training")))
sample(names(n)[n == min(n)], 1)

What would happen? When a participant submits the intake, formr counts how many people so far got each condition and stores the one with fewer in intake$condition. If both have the same number, R picks one at random. The participant keeps that condition, and the Skip Forward sends them down its path.

There are a few trade-offs:

  • The code counts everyone who got a condition, including people who stopped later. Counting only those who finished would make up for different drop-out, but then everyone who starts before the next person finishes lands in the same group.
  • When the counts differ, the order in which people arrive decides their group, not chance. If your design needs random assignment, use a Shuffle.
  • calculate items only work in classic surveys, not on v2.
Comparing a participant with everyone so far

Read everyone's answers in the feedback text itself and set the participant's answer against them. Here it's a Stop Point, but a note in a survey or an email works the same way:

  • Pos. 10. a survey called wellbeing with the item life_satisfaction (1 to 7).
  • Pos. 20. a Stop Point with this feedback text:
```{r}
formr_api_authenticate()
everyone <- formr_api_results(surveys = "wellbeing", remove_test_sessions = FALSE)
test <- formr_api_sessions(.formr$run_name, testing = TRUE, limit = 10000)
everyone <- everyone[!everyone$session %in% test$session, ]
others <- everyone$life_satisfaction[!is.na(everyone$life_satisfaction)]
below <- round(100 * mean(others < wellbeing$life_satisfaction))
```

You rated your life satisfaction `r wellbeing$life_satisfaction` out of 7.
That's higher than `r below`% of the `r length(others)` people
who have answered so far.

wellbeing$life_satisfaction is the participant's own answer, which formr supplies without the API. everyone holds every real participant's, theirs included. Knit R & Markdown shows how to make a plot instead. With Test Run, the page also shows the R code and its messages. Participants see neither.

In the first days, "everyone so far" is a handful of people, and the numbers jump around. You may want to show the comparison only once length(others) is 30 or more.

Waiting until enough people are there

To hold participants until enough of them have reached a step, e.g. until all 25 students in a class have given their ratings, loop them through a waiting page that reloads itself.

  • Pos. 10. a survey called ratings.
  • Pos. 20. a Skip Forward with the condition below. If it's true, it skips forward to Pos. 50.
  • Pos. 30. a survey called waiting, with a note ("Waiting for the others. This page reloads itself.") and a submit 10000 button.
  • Pos. 40. a Skip Backward which checks TRUE, so it always goes back to Pos. 20.
  • Pos. 50. a Stop Point with the class's results (see above).
formr_api_authenticate()
people <- formr_api_sessions(.formr$run_name, limit = 10000)
sum(people$position >= 20) >= 25

What would happen? A participant who has given their ratings is checked at Pos. 20. Until 25 people have got that far, they see the waiting page. It submits itself after 10 seconds, and the Skip Backward sends them back to the check. When the 25th person arrives, everyone moves on within 10 seconds.

The catches:

  • Everyone who has reached Pos. 20 counts, including someone who closed the page while waiting.
  • Test users count too, so you can try the loop with a few of them and a lower number. Add testing = FALSE before the real thing.
  • Each round runs your code again, for every participant who waits. Don't make the interval much shorter, and keep the monthly compute limit in mind if this instance has one.
  • If the wait can take hours or days, use a Pause with the same code as relative to instead, followed by an Email that invites participants back. formr checks the condition again every 10 minutes.
  • To start the group yourself, move the people who wait on to Pos. 50 from your computer with formr_api_session_action() (see Moving participants on).

Making your study an app with push notifications

Generate an app manifest in your study's settings, ask participants in your first survey to add the study to their home screen and to allow notifications, and put a Push Notification module wherever the study should alert them. Participants then open your study from an icon on their phone, and you can remind them without knowing their email address or phone number. The example is a 14-day study with a short questionnaire every evening.

Setting up

In your study's Settings, tab App, upload your icons (Upload PWA Icon/Splash Screen Folder, file names under App) and click Generate Manifest. Do this before anyone installs the study, because an iPhone reads the manifest only when the study is added to it.

Generating the manifest also sets the Cookie/Session Lifetime (tab General) to at least a year, so that the phone remembers the participant between visits. That counts only for participants who allowed functional cookies, which is what request_cookie asks for. Leave Automated actions on, too, or Pauses end and notifications go out only when participants open the study themselves.

Then build the first survey, called intake here, one step per page (a submit item ends each page). If this instance offers v2, make it a v2 form. R then sees what became of a subscription. In a classic survey, intake$notifications keeps the subscription the participant first gave, also after they turned notifications off or the push service dropped it.

  1. request_phone. On a phone, it answers itself (is_phone). On a computer, it shows a QR code with the participant's own link, so they carry on with their phone as the same participant (is_desktop if they stay on the computer).
  2. add_to_home_screen. Its button shows participants how to add the study on their phone and browser. Adding it doesn't open it, so tell them in the label to open the study from the new icon. Once participants open the study from its icon, a classic survey stores installed and a v2 form already_added. Where the browser's own install prompt succeeded (Chrome and Edge, e.g. on Android), they store installed and added already in the browser.
  3. request_cookie and push_notification, here named cookies and notifications. cookies stores consent_given (functional_cookie if they had agreed before). notifications stores what formr needs to reach them (a text containing endpoint), or else why not, e.g. permission_denied.
  4. email, so that participants without notifications can be asked for an address. Its showif is !grepl("endpoint", notifications, fixed = TRUE) in a classic survey and !contains(notifications, "endpoint") in a v2 form.

The four app items are required unless you put * in their optional column, and a required one lets participants go on only once they've done what it asks. Then everyone who goes on has the app and notifications, but you lose those whose phone can't, e.g. an iPhone older than iOS 16.4. Here, notifications and email are optional. Participants without notifications get emails if they give an address. Those who give neither still go on to daily (Pos. 45 below), but nothing invites them.

On iPhones

An iPhone or iPad gets notifications only from a study that's on its home screen and opened from there, and only from iOS 16.4 on. In the browser, the push_notification button is greyed out and tells participants to add the study first. It stores ios_install_required (not_supported in a v2 form), and if it's required, they can't go on. That's why add_to_home_screen comes a page earlier. When participants open the study from its new icon, they're back on that page, and the next one can ask for notifications. On Android, the browser can ask too.

Sending the notifications

Pos. 10. the survey intake.
Pos. 20. a Pause with wait until time 19:00.
Pos. 30. a Push Notification with the title "Time for today's questions", the message "It takes two minutes.", Priority High and Time to Live 10800 (three hours).
Pos. 40. a Skip Forward with the condition grepl("endpoint", intake$notifications, fixed = TRUE), which jumps to 60 if it's true.
Pos. 45. a Skip Forward with the condition is.na(intake$email), which jumps to 60 if it's true.
Pos. 50. an Email with the same invitation and {{login_link}}. The recipient field contains intake$email.
Pos. 60. a survey called daily, with Start editing within 180 and Inactivity Expiration 30 in its settings.
Pos. 70. a Skip Backward with the condition nrow(daily) < 14, which jumps back to 20 if it's true.
Pos. 80. a Stop Point that thanks them.

What would happen? A participant finishes intake on their phone at lunchtime and waits at the Pause. At 19:00, formr ends the Pause and sends the notification. If their phone is off, the push service keeps trying for three hours. Participants without notifications skip the Push Notification module and get the email instead. A tap on the notification opens daily. Someone who hasn't started it by 22:00, or who leaves it alone for half an hour, is moved on and waits at the Pause for the next evening. After 14 evenings, answered or missed, they reach the Stop Point. The module's other fields are explained under Push notification.

Checking who gets them

Before you invite anyone, go through the study yourself with Test Run, on an iPhone and an Android phone, with the Pause shortened to a few minutes. request_phone's QR code takes you from the computer to the phone.

Your study's Push Messages page lists every notification, with its position, its status and when it was tapped. The statuses:

  • success: the push service took the message. That doesn't prove the phone showed it.
  • no_subscription: the participant hasn't allowed notifications, turned them off, or their phone dropped them.
  • failed: the push service turned the message down, and the Error column says why. If the subscription is gone (404 or 410), formr stops sending to it.
  • message_parse_failed or title_parse_failed: your R code in the message or title didn't work. The participant got nothing, the study moved on, and formr emailed you.

The table at the top counts, for each push service (Apple's, Google's and so on), how many of the last 30 days' messages were tapped. If hardly any of one service's messages are tapped while the others' are, its phones may not be showing them. Try one yourself. Opening the study from its icon instead doesn't count as a tap.

What participants experience
  • The icon opens the study where the participant is, with their user code, even if the phone has forgotten them. If it ever opens without knowing who they are, it asks for their user code or the link in their latest invitation.
  • A tap on a notification opens the study where the participant is now. A study page that's already open reloads only if the study has moved on, so nothing they typed is lost. Someone looking at the Pause at 19:00 sees daily appear by itself.
  • On iPhones, each notification stays until it's tapped or cleared, so someone who missed three evenings finds three, and any of them opens the study where it is now. Elsewhere, a new one replaces the earlier ones (more under Push notification).
  • If a phone drops its subscription, formr makes a new one the next time the participant opens the study there, if need be after a tap. Someone who removed the app and added it again is asked to allow notifications again.
  • On the study's settings page ({{settings_link}}, also in a new study's footer), participants can turn notifications off and on again.
When notifications don't reach everyone

You have the following options:

  1. Email the participants who didn't allow notifications, as at Pos. 40 to 50 above. In a classic survey, this goes by what they answered in intake, so someone who turns notifications off later, or whose phone drops them, isn't emailed. That's why we recommend a v2 form for intake. There, R sees the item as it is now (not_requested once they've turned notifications off, expired: and a code once the subscription is gone), so they no longer pass Pos. 40. Those who had notifications at first gave no address, and the Skip Forward at Pos. 45 moves them on. You'll find them on the Push Messages page, as no_subscription or failed.
  2. Text them instead, with an External link that calls an SMS service (see the wiki's How to send text messages). You need their phone number and an account with such a service.

Short answers

Time zones

All times in formr are in the time zone of this formr instance, which is Europe/Berlin. A Pause or Waiting Time that waits until 19:00 waits until 19:00 there, and the timestamps in your data (created, ended) are in that zone too.

If your participants live elsewhere, ask for their zone with a timezone item (below, zone in a survey called intake). It preselects the participant's own zone in most browsers, so keep it required and ask them to check it (Item types). Then compute the time in the Pause's relative to, and leave its date and time fields empty. The last line below adds the UTC offset, without which formr would read the time in the instance's zone.

library(lubridate)
zone <- gsub(" ", "_", gsub(" - ", "/", intake$zone)) # "America - New York" to "America/New_York"
evening <- update(now(tzone = zone), hour = 19, minute = 0, second = 0)
if (evening < now()) evening <- evening + days(1)
format(evening, "%Y-%m-%dT%H:%M:%S%z")

lubridate comes with formr's R package and handles daylight saving time. Adding a fixed number of hours instead is wrong for part of the year, because clocks change on different dates in different countries.

The language of buttons and messages

Participants see what you wrote as you wrote it: item and choice labels, the labels of your submit items, and the texts of your pauses, stop points and emails. What's left are formr's own texts around your items.

  • On v2, set Participant language in the survey's settings, e.g. de. formr's buttons and messages come in English and German, and in English for any other language. With Button labels, you word the Next button and the last page's button yourself, in any language.
  • In a classic survey, formr's own texts are in English, e.g. the Back to Page buttons of Custom Paging. The messages about missing or invalid answers that show before a page is sent, and the date picker, follow the language of the participant's browser.

The cookie bar at the bottom of the page follows the browser's language, English or German, on both.

The Form (v2) tab lists the v2 settings.

R packages

Your R code can use the packages installed on this instance's OpenCPU server. The formr R package is always there, with the packages it needs, such as dplyr, ggplot2 and lubridate. Which others there are is up to the people who run the instance, so check before you build on one. Make a new study with only a Stop Point, put this in its text and open the study with Test Run:

`r isTRUE(requireNamespace("ggdist", quietly = TRUE))`

If it shows TRUE, the package is there. Try the functions you need with Test Run too: a package can load while some of its functions need another package that this instance doesn't have. If it shows FALSE, ask the people who run this instance to install it. Tell them its name and, if it isn't on CRAN, where it comes from. The R Helpers tab describes what the formr package does.

"There was a computational error."

It means that some R code failed, e.g. in an item's label or choices, or on a pause or stop page. (Before formr 2.0, a survey said "There was a problem dynamically knitting something to HTML using openCPU.") Participants see only that, and formr emails you (When a module fails).

On v2, participants see no message. A label or choice whose R fails stays empty, an item whose value fails gets none, and a note_iframe says "This content is temporarily unavailable." formr emails you. With Test Run, R's error shows in the place of what's missing.

In a classic survey and on other pages, with Test Run, you see R's error, the R Markdown formr tried to knit and, where this instance offers it, Open in R Fiddle to run it in your browser. The usual causes:

  • a typo in a survey or item name,
  • answers from a survey the participant hasn't reached yet,
  • a package this instance doesn't have (R packages),
  • library() or detach() of a package OpenCPU uses itself, such as jsonlite.

If the page shows but looks wrong: text with R in it goes through R Markdown, which needs a space after a heading's # and turns lines indented by four spaces into code (Knit R & Markdown).

The back button

Participants can go back to earlier pages of a survey if you allow it in the survey's settings. In a classic survey, turn on Custom Paging, which gives each page Back to Page buttons for the pages before it (it can't be turned off again, see Survey settings). On v2, tick Allow "Previous" button. While it's off, the browser's back button doesn't go back either.

Without these settings, the browser's back button is no reliable way back, and neither is a button of your own that calls history.back(). In a classic survey, a <button> you put in a label sends the page, which is why such a button moves participants forward.

Neither setting takes participants back into a survey they have finished. To let them fill it out again, send them back with a Skip Backward. That adds a new row of answers and keeps the old one.

Bots and fake responses

formr has items that make automated responding harder, and items that help you spot it afterwards (Item types).

  • bot_check has the participant's browser solve a small puzzle before the page can be sent. It runs on this formr server, without a third party. Scripts pay for every response, but anyone who answers by hand passes.
  • turnstile stores the verdict of Cloudflare's bot detection. It sends data about participants to Cloudflare, needs their consent, and exists only where this instance's administrators have set it up.
  • data_quality and agent_probe record signs of automated or careless responding and block no one (admin documentation).

bot_check and turnstile work only on v2. No check catches everyone. Decide before you collect data which ones you'll exclude people on, and say so in your consent text and preregistration. If you recruit through a panel, its own checks come on top.

Phones and small screens

formr's pages adapt to small screens by themselves. On screens up to 768 pixels wide, the choices of mc items are stacked at full width and rotated labels are straightened. In a classic survey, an mc_heading disappears there, and mc items with hide_label show their choice labels again. So a table of mc items turns into a list, because a table doesn't fit on a phone. A v2 form shows no mc_heading on any screen.

What to check:

  • Look at your study on a phone before it starts, not only in a narrow window on your computer.
  • mc_horizontal keeps the choices side by side on small screens. Use it only for short scales that fit.
  • mc_vertical stacks the choices on every screen, for items with many options.
  • On v2, the Solo layout shows one item per screen (Layouts).

The classes are described under CSS classes.

formr studies


In formr, a study (called a "run" in the admin area) contains your complete design. All the things that a single participant is going to do should take place in one study. Designs can range from the simple (a single survey or a randomised experiment) to the complex (like a diary study with daily reminders by email and text message or a longitudinal study tracking social network changes).

Inside a study, participants' data is connected, so you can track how many times a participant filled out her diary or whether her social network grew in size since the first measurement time point.

So, why "run"? In formr, runs consist of simple modules that are chained together linearly. Because most modules are boombox-themed, it may help to think of a tape running. Using controls such as the skip backward button, the pause button and the stop button, you control the participant's progression along the run. Surveys can be thought of as the record button: whenever you place a survey in your run, the participant can input data.

Data for the control modules are supplied on-the-fly to the statistics programming language R. Therefore, you can dynamically generate feedback graphics for your participants with minimal programming knowledge. With more programming knowledge, nothing keeps you from making full use of R. You could for example analyse the sentiment of participants' diary entries and invite them to follow-up surveys only if they express anger.

Since studies contain your complete design, it makes sense that their administration side is where every user management-related action takes place. There is a user overview, where you can see at which position in the study each participant is and when they were last active. Here, you can send people custom reminders (if they are running late), shove them to a different position in the study (if they get lost somewhere due to an unforeseen complication) or see what the study looks like for them (if they report problems).

The study's admin area is also where you customise its look, upload files (such as images, videos, Javascript files), control access and enrolment. In addition, there are logs of every email sent, every position a participant has visited and of automatic progressions.

Your live study can be found at https://study.researchmixtape.com/yourStudyName/. Once you set its access to People who have the link can access, anyone who opens it starts your study.

If you recruit through a panel such as Prolific, you give the panel this link and it adds its own participant ID to it. A get item in your first survey saves that ID.

Each participant has their own user code. It's part of their link (?code=…) and their browser remembers it, so participants can close the tab and pick up where they left off. To send someone a link with their own user code, put {{login_link}} in an Email. If you need to build a link yourself, use {{login_code}}. For a link that other people get, e.g. informants who rate the participant, use only the last ten characters of the code (see Peer ratings).

A new participant on every visit

If you add ?_new_session=1 to your study's link, every visit starts the study as a new participant, with a new user code. That's what you need when many participants take part one after another on the same computer, e.g. in the lab. Without it, the next person would carry on where the previous one stopped.

  • Other parameters come along. ?_new_session=1&rated=P1 becomes ?code=…&rated=P1, so your survey can still read rated.
  • It only works on the study's own address, not on a link to a page inside the study.
  • It doesn't let in anyone who couldn't get in before. The study still needs its access set to People who have the link can access.
  • Once the study has started, the address shows the participant's own user code, so reloading or bookmarking that page keeps them in the study they just started.

Don't use it for a link people might open twice, like the one in a reminder email, because every visit counts as a new participant. Use {{login_link}} there.

Placeholders

In the body of an Email, the text of a Stop Point and an External link, formr replaces these placeholders with the participant's own links and code. They don't work anywhere else, e.g. not in an email's subject, a Pause's text, a push notification or a survey.

{{login_link}}
a link to the study with the participant's user code, so it opens where they are. Its text is "Login Link".
{{login_url}}
the same address without the link around it. Use it to give the link your own text, e.g. [Start today's diary]({{login_url}}).
{{login_code}}
the participant's user code, to build links of your own, e.g. to another survey software. In an Email or a Stop Point, put an address that contains a placeholder in angle brackets (<https://…?id={{login_code}}>). Whoever has the whole code can carry on as the participant, so in links for other people use only its last ten characters (see Peer ratings). In a Stop Point with R code you can also write `r .formr$login_code` (in an address, `r URLencode(.formr$login_code, reserved = TRUE)`), which works on instances that don't replace placeholders there, too.
{{settings_link}}
a link to the participant's settings page for your study ("Settings Link"). If your study has their email address, they can stop its emails there for a week, two weeks, a month or for good, and Email modules skip them meanwhile. They can also choose whether this browser remembers them, turn push notifications on or off, log out, and see their user code, which they can send you if they want their data deleted. A new study's footer links to this page too.
{{settings_url}}
the same address without the link around it.
{{logout_link}}
a link that logs the participant out of the study in this browser ("Logout Link"), e.g. on a shared computer, so the next person doesn't carry on in their place. Their answers stay saved, and their login link brings them back.
{{logout_url}}
the same address without the link around it.

The _link placeholders are HTML links, so they belong in an Email or a Stop Point. In an External link, use {{login_code}} or one of the _url placeholders.

Module explanations

Surveys are series of questions (or other items) that are created using simple spreadsheets/item tables (e.g. Excel).

Survey item tables are just spreadsheets and they can just as easily be shared, reused, recycled and collaboratively edited using e.g. Google Sheets.

Surveys can remain fairly simple: a bunch of items that belong together and that a participant can respond to in one sitting. For some people, simple surveys are all they need, but in formr a survey always has to be part of a (simple) study.

Surveys can feature various items, allowing e.g. numeric, textual input, agreement on a Likert scale, geolocation and so on.

Items can be optionally shown depending on the participant's responses in the same survey, in previous surveys and entirely different data sources (e.g. data your R code fetches from another service). Item labels and choice labels can also be customised using knitr, so you can e.g. refer to a participant's pet or last holiday location by name or use people's preferred term of address.

If you use R, formr includes a few nice timesavers in its R package on Github. Data import can be automated without any funny format business. Items will be correctly typed according to the item table, not according to flawed heuristics. You will also have item and value labels available in R.
If you name your items according to the schema BFI_extra_2R, items with an R at the end can be automatically reversed and items ending on consecutive numbers with the same prefix will be aggregated to a mean score (with the name of the prefix). Using our R package codebook you can then document the data, as well as automatically generate internal consistency analyses and item frequency plots. Hence, some tedious manual data wrangling can be avoided, especially if you start giving your items meaningful and memorable names early on. The formr:: functions are also always available, whenever you use R inside formr studies and surveys.

A v2 form is a survey on formr's new engine. It asks the questions from your item table as a classic survey does, but pages change without reloading, showifs react at once, answers are saved as participants go, and a page sent without a connection waits on the device until the participant is back online. It also has a layout with one item per screen ("solo") and buttons in the participant's language.

There is no separate button for it. Add the survey with Add Survey, and if the survey is on v2 (marked (v2) in the list), the module is a Form. To put a survey on v2, upload it on v2 or move it on its settings page. Elsewhere in your study, R reads a v2 form's data like a classic survey's: survey_name$item.

One rule changes for authors. In a v2 form, showif is JavaScript and runs in the participant's browser. R goes in the value column, and a hidden item's value is how you get an R result into a showif. The rest stays the same: the spreadsheet format, the item types (except calculate, which a v2 form doesn't run) and R elsewhere in your study. Read the v2 guide before you switch a study that is already collecting data.

These are external links - use them to send participants to other, specialised data collection modules, such as a social network generator, a reaction time task, another survey software (we won't be too sad), anything really. However, you can also simply call upon external functionality without sending the participant anywhere – one popular application of this is sending text messages via an R API call.

If you insert the placeholder {{login_code}}, it will be replaced by the participant's user code, allowing you to link data later (but only if your external module picks this variable up!).

By default, formr ends the module as it sends the participant off. If the other side should decide when they're done, tick end using API. formr then sends the participant there on every visit until the other side makes one of the calls under Ending an External link through the API. After the call, the study goes on by itself: a Pause starts waiting, an Email goes out, and a survey waits for the participant's next visit (if the study's Automated actions are off, the next module waits for it, too). With Expire after … minutes, the study moves on anyway that many minutes after the participant reached the module. If you set or shorten it while participants are there, they go on that many minutes after you saved it, or at their next visit if they reached the module that long ago. Leave it empty to wait as long as it takes. Test users are kept there too, so if your service makes no call for them, send them on in Users. If an External link is your study's last module, keep it open this way (tick end using API) or put a Stop Point after it. To send more data along, or to call another service without sending anyone away, write the address in R (below).

The External link can also be R code. If it returns an address (starting with http), the participant is sent there. If it returns anything else, e.g. FALSE after an API call, the study moves on without sending them anywhere. The value is kept, and R code later in the study reads it as survey_unit_sessions$result_log (see R Helpers): a list or data frame as JSON, and of a vector, an unnamed list or a data frame only the first element or row. Nothing is kept for FALSE, NULL and empty results. To send more data along, build the address in R: paste0('https://example.org?code={{login_code}}&age=', demographics$age).

Push notifications are a way to send notifications to participants. To be able to use them, you need to generate an application manifest in your study's settings (tab App, Generate Manifest).

The manifest is a JSON file that describes your app. It is used to generate a PWA and a shortcut icon on the participant's device.

Once your study has a manifest, you can add special items (see the Progressive web app items section of available items) like add_to_home_screen to your surveys. This will add a button to the participant's device that allows them to add your study to their home screen. request_phone will guide the user to switch to a mobile device. And push_notification will ask the user to allow push notifications for your study. We recommend a v2 form for the survey with this item, because in a classic survey, R doesn't see when participants turn notifications off later (more). You can also insert the request_cookie item to explicitly ask participants to allow functional cookies which won't expire when the app is closed.

Put a Push Notification module where your study should send a notification. Participants who haven't allowed notifications skip it, and the study moves on. On iPhones and iPads, participants have to add the study to their home screen before they can allow them (iOS 16.4 or later).

Title, Message
what the notification says. Both can use inline R, e.g. `r demographics$first_name`. Without a title, the notification is titled "Notification". A very long message is shortened.
Priority
Normal or High (the default). High wakes a sleeping phone. A Normal notification can be held back until the participant turns on the screen, so use High for prompts that have to arrive on time. There's nothing above it.
Time to Live
how long, in seconds, the push service keeps trying to deliver the notification to a phone that is off or offline. At least 60 seconds, at most four weeks. Empty means one day (86400).
Badge Count
the number shown on the study's app icon, where the device shows badges. Empty or 0 shows none.
Notification Mode
Sound + Vibration, Sound Only or Silent.
hand checkbox
(Require user interaction to dismiss) keeps the notification on screen until the participant taps or closes it, where the browser supports that.
bell checkbox
(Show new notification even if one exists) no longer changes anything, because every push now shows as a notification of its own.

A tap on the notification opens the study where the participant is now. If a page of the study is already open, it comes to the front and reloads only if the study has moved on since, so nothing typed into a survey is lost. On iPhones, each notification stays until the participant taps or clears it. Elsewhere, a new notification replaces the study's earlier ones, and they close once the participant has had the study in front of them for a few seconds (5, or 20 on a v2 form). Your study's Push Messages page lists every notification sent and which ones were tapped. The module's Test shows the title and the message with a participant's data in them, and sends nothing.

Skip backward allows you to jump back in the study, if a specific condition is fulfilled.

This way, you can create a loop. Loops, especially in combination with reminder emails are useful for diary, training, and experience sampling studies.

The condition is specified in R and all necessary survey data is automatically available. The simplest condition would be TRUE – always skip back, no matter what. A slightly more complex one is nrow(diary) < 14, this means that the diary must have come up at least fourteen times (nrow counts every time it opened for the participant, also the times they missed; sum(!is.na(diary$ended)) counts the finished ones). Even more complex: nrow(diary) < 14 | !time_passed(days = 20, time = first(diary$created)), this means that at least 20 days must have passed since the first diary opened and that the diary must have come up at least 14 times. The diary guide builds a whole diary study step by step. But any complexity is possible, as shown in Example 2.

Example 1

A simple diary. Let's say your study contains

  • Pos. 10. a survey in which you find out the participant's email address
  • Pos. 20. a pause which always waits until 6PM on the next day
  • Pos. 30. an email invitation
  • Pos. 40. a survey called diary containing your diary questions, with Start editing within and Inactivity Expiration set in its settings
  • Pos. 50. You would now add a Skip Backward with the following condition: nrow(diary) < 14 and the instructions to jump back to position 20, the pause, if that is true.
  • Pos. 60. At this position you could then use a Stop Point, marking the end of your diary study.
What would happen?

Starting at 20, participants would receive their first invitation to the diary at 6PM the next day after enrolling. After completion, the Skip Backward would send them back to the pause, where you could thank them for completing today's diary and instruct them to close their web browser. Automatically, once it is 6PM the next day, they would receive another invitation, complete another diary etc. Someone who doesn't start a diary in time is moved on as well, back to the pause. After 14 evenings, filled out or missed, the condition would no longer be true and they would progress to position 60, where they might receive feedback on their mood fluctuation in the diary.

Without the diary's two time limits, a participant who misses one evening stays at the diary, and no further invitation goes out (see the diary guide).

Example 2

But you can also make a loop that doesn't involve user action, to periodically check for external events:

  • Pos. 10. a short survey called location that mostly just asks for the participants' GPS coordinates and contact info
  • Pos. 20. a pause which always waits one day
  • Pos. 30. A Skip Backward which checks the weather at the participant's GPS coordinates. If no thunderstorm occurred there, it jumps back to the pause at position 20. If a storm occurred, however, it progresses.
  • Pos. 40. an email invitation
  • Pos. 50. a survey called storm_mood containing your questions regarding the participant's experience of the storm.
  • Pos. 60. A stop button, ending the study.
What would happen?

In this scenario, the participant takes part in the short survey first. We obtain the geolocation, which can be used to retrieve the local weather using API calls to weather information services in the Skip Backward at position 30. The weather gets checked once each day (pause at 20) and if there ever is a thunderstorm in the area, the participant is invited via email (40) to take a survey (50) detailing their experience of the thunderstorm. This way, the participants only get invited when necessary, we don't have to ask them to report weather events on a daily basis and risk driving them away.

Computed jumps

Your R code can also return a position number instead of TRUE or FALSE, and the participant goes straight to that position. It works the same in both skips, see Computed jumps under Skip Forward.

This simple component allows you to delay the continuation of the study, be it
until a certain date (1 January for research on new year's hangovers),
time of day (asking participants to sum up their day in their diary after 7PM)
or to wait relative to a date that a participant specified (such as her graduation date or the last time he cut his nails).

  • Pos. 10. a survey collecting personality and contact info + the graduation date of university students
  • Pos. 20. a pause which waits until 4 months after graduation
  • Pos. 30. an email invitation
  • Pos. 40. another personality survey
  • Pos. 50. A stop button, ending the study. On this last page, the students get feedback on how their personality has changed after graduation.

A Pause has these fields:

wait until time
a time of day. If it has already passed when the participant arrives, the pause lasts until that time on the next day.
wait until date
a day. The pause ends as that day starts, or at the wait until time on that day.
wait this many minutes
how long to wait (convert days turns days into minutes). The minutes count from when the participant arrived at the pause, or from relative to. If you set minutes, the date and time fields are ignored.
relative to
R code that returns a date and time, e.g. graduates$graduation_date. Without minutes, the pause lasts until then (until the wait until time on that day, if you set one). It can also return TRUE to end the pause, or FALSE to keep waiting. formr then asks again every 10 minutes.
Text to show while waiting
what participants see if they open the study during the pause.

formr reads most ways of writing a date: 2026-10-26 17:36, 26.10.2026 17:36, with a time zone (2026-10-26T16:44Z) or in words (tomorrow). Before formr v1.12.0, dates in the other formats ended the pause at once. A number such as 1000 is no date, and neither is a day the calendar doesn't have (2026-02-30). Then the participant waits at the pause, and formr emails you.

formr reads times in the instance's time zone, Europe/Berlin, and doesn't see the zone an R date-time is in, so convert others with lubridate::with_tz(x, "Europe/Berlin") (see also Time zones).

See the Knitr & Markdown section to find out how to personalise the text shown while waiting.

Skip forward allows you to jump forward in the study, if a specific condition is fulfilled.

This way, you can create filters, and parallel paths or branches in a study. Filters are useful to screen participants. You may need parallel paths in a study to randomise people to one experimental branch out of many, or to make sure a certain part of your study is only completed by those for whom it is relevant.

Example 1 a filter/screening

Let's say your study contains

  • Pos. 10. a survey (depression) which has an item about suicidality
  • Pos. 20. a Skip Forward which checks depression$suicidal != 1. If the person is not suicidal, it skips forward to pos 40.
  • Pos. 30. At this position you would use a Stop Point. Here you could give the participant the numbers for suicide hotlines and tell them they're not eligible to participate.
  • Pos. 40. Here you could do your real survey.
  • Pos. 50. A stop button, ending the study.
What would happen?

Starting at 10, participants would complete a survey on depression. If they indicated suicidal tendencies, they would receive the numbers for suicide hotlines at which point the study would end for them. If they did not indicate suicidal tendencies, they would be eligible to participate in the main survey.

Example 2 different paths

Let's say your study contains

  • Pos. 10. a survey on optimism (optimism)
  • Pos. 20. a Skip Forward which checks optimism$pessimist == 1. If the person is a pessimist, it skips forward to pos 50.
  • Pos. 30. a survey tailored to optimists
  • Pos. 40. a Skip Forward which checks TRUE, so it always skips forward to pos 60.
  • Pos. 50. a survey tailored to pessimists
  • Pos. 60. At this position you would thank both optimists and pessimists for their participation.
What would happen?

Starting at 10, participants would complete a survey on optimism. If they indicated that they are pessimists, they fill out a different survey than if they are optimists. Both groups receive the same feedback at the end. It is important to note that we have to let the optimists jump over the survey tailored to pessimists at position 40, so that they do not have to take both surveys.

Some older Skip Forwards show How should participant skip?, with automatically or if user reacts for each outcome. With if user reacts, the participant only moves on when they next open the study. formr is phasing this out, and new Skip Forwards don't offer it. Computed jumps always happen at once.

Computed jumps

Your R code can also return a position number instead of TRUE or FALSE. The participant then goes straight to that position, and the skip forward to field is ignored. That way, one module can send participants to different places: c(30, 50, 70)[screener$arm] sends arm 1 to position 30, arm 2 to 50 and arm 3 to 70. It works the same in a Skip Backward.

formr reads what your code returns like this:

  • TRUE or FALSE: the usual skip. The participant goes to the position in the field, or on to the next module.
  • 0 and 1 always mean FALSE and TRUE, never positions 0 and 1. So a condition that returns 1 or 0, such as screener$consent on an item coded 1/0, works as it always has. One that can return more, such as sum(x) or nrow(df), is a position in a module made since formr v1.10.3: write sum(x) > 0 or nrow(df) > 0 for a yes/no. To send someone to position 1, renumber your modules.
  • 2 or higher: the position to go to.
  • Decimals are rounded to the nearest whole number, halves up: 29.5 and 30.4 both mean position 30. Rounding comes first, so 1.9 becomes 2 and jumps.
  • Several values: only the first one counts, and the module's log gets a warning. Return one value.
  • Anything else (a negative number, text, a date) is read as TRUE or FALSE, with a warning in the log. Don't rely on it.
  • NA or an empty result (logical(0) or NULL, usually from a comparison with a column this participant doesn't have): the participant waits at the module, and formr emails you how to fix it, e.g. with isTRUE(survey$consent == "yes"). Before formr v1.10.3, an empty result counted as FALSE.

The number has to match a module's position exactly. If no module is at that position, the participant carries on with the next module and you get an email. The direction is up to the number: a Skip Forward that returns a position before it sends the participant back. And because it's a position, not a module, check your computed jumps after you reorder your study.

Skip modules created before formr v1.10.3 have their condition wrapped in as.logical({ … }). Before computed jumps, any number other than 0 meant TRUE, and the wrapper keeps that reading (as.logical(25) is TRUE), so an older study keeps its routing. A wrapped condition that returns an R Date or POSIXct also keeps its old reading: a past moment is TRUE, a future one FALSE. A date written as text is NA and makes the participant wait. To return a position number from such a module, remove the wrapper.

The Routes to column in the module's Test shows where each participant would go. Use it to check your code before you send anyone through.

Waiting Times are like Pauses, but instead of making the participant wait, we wait for the participant.

By waiting for the participant for a certain amount of time, we can make sure that people are reminded to participate in our diary study after one hour—but only if they need a reminder. We can also make sure that a part of a study is only accessible at certain times of day.

A Waiting Time has the same fields as a Pause, without the text. Without relative to, its minutes count from when the participant reached the Waiting Time, which is usually right after the module before it, e.g. the invitation email. In If participant shows up before the waiting time expires, move to position, enter where participants go when they open the study in time. Otherwise they continue with the next position once the time is up. Its times are in the instance's time zone, too, so convert others with lubridate::with_tz(x, "Europe/Berlin").

A Waiting Time only waits when formr reaches it in the background, e.g. after a Pause and an invitation Email, as in the example below, or when you send a participant there from Users. If the participant reaches it during their visit, e.g. right after a survey, that counts as showing up: while its time isn't up they go to the position you entered at once, otherwise on to the next module. If they should leave first, put a Pause before it.

Example 1 reminder

Let's say your study contains

  • Pos. 10. a pause (e.g. let's say we know when exchange students will arrive in their host country, and they cannot answer questions before they've been there one week)
  • Pos. 20. Now we have to send our exchange students an email to invite them to do the survey.
  • Pos. 30. a Waiting Time for 7 days. If the user clicks the link to answer questions, the study jumps to position 50, the survey. If 7 days go by without a reaction, the study moves on to the next position, the reminder.
  • Pos. 40. This is our email reminder for the students who did not react after 7 days.
  • Pos. 50. the survey we want the exchange students to fill out. Its Start editing within is 7 weeks.
  • Pos. 60. Because this is a longitudinal study, we now wait for our exchange students to return home. The rest is left out.
What would happen?

Once students have been abroad for a week, the Pause ends and they get the invitation. If they open the study within 7 days, the Waiting Time sends them to position 50, the survey. Otherwise the study moves on to position 40 after 7 days, and they get the reminder. The survey then waits up to 7 weeks for them to start it (its Start editing within). Whoever finishes it, or hasn't started by then, moves on to position 60, which waits until they return home. To end the survey for those who started but never finish, set finishing editing within too.

You will always need at least one. These are stop points in your study, where you can give short or complex feedback, ranging from "You're not eligible to participate." to "This is the scatter plot of your mood and your alcohol consumption across the last two weeks".

If you combine these end points with Skip Forward, you can have several in your study: You would use the Skip Forward to check whether participants are eligible, and if so, skip over the stop point between the Skip Forward and the survey that they are eligible for. This way, ineligible participants end up in a dead end before the survey. On the Edit Run page, you can see green counts of the number of people on this position on the left, so you can see easily how many people are ineligible by checking the count.
See the Knitr & Markdown section to find out how to generate personalised feedback, including plots. The Feedback text can also use the placeholders, e.g. {{settings_link}}.

This is a very simple component. You simply choose how many groups you want to randomly assign your participants to. We start counting at one (1), so if you have two groups you will check shuffle$group == 1 and shuffle$group == 2. You can read a person's group using shuffle$group. If you generate random groups at more than one point in a study, you might have to use the last one tail(shuffle$group,1) or check the unit id shuffle$unit_id, but usually you needn't do this.

If you combine a Shuffle with Skip Forward, you could send one group to an entirely different arm/path of the study. But maybe you just want to randomly switch on a specific item in a survey - then you would use a "showif" in the survey item table containing e.g. shuffle$group == 2. That works in a classic survey. In a v2 form, bring the group in with a hidden item whose value is shuffle$group (Bridging R into a showif). The randomisation always has to occur before you try to use the number, but the participants won't notice it unless you tell them somehow (for example by switching on a note telling them which group they've been assigned to).

Study settings


Each study has a settings page: open the study in the admin (Runs, then the study) and click Settings in the menu on the left. Who can take part, and a few other controls, sit at the top of Edit Run, where you put the study together. The admin still calls a study a run, so the labels below do too.

You can also read and change most of these settings through the API (PATCH /v1/runs/{name}).

Publicness

The four buttons next to Publicness at the top of Edit Run decide who can open your study. A new study starts on the first.

Private

Only you and test users can access the study. Everyone else sees your service message. Use it while you build and test.

Closed to newcomers

You and people who already have an access code can access (no new users can enrol). Participants who already started carry on, newcomers see the service message. Use it to stop recruiting without locking out the people who are halfway through.

Open by link

People who have the link can access. Anyone who opens your study's link starts it. That's what you need to recruit, e.g. through a panel.

Public

Link is public, everyone can access. As above, and the study is also listed on this instance's Studies page, if it has one, with its title and public blurb.

You can't leave the first level while Expires On is empty or has passed (an empty date is fine where the instance sets no maximum). New studies get the latest date allowed, so this only stops you if you cleared it. Some instances also require a privacy policy first. If something is missing, the admin says so when you click the button.

Edit Run

Lock

makes the modules on Edit Run read-only, so you can't change anything by accident. Click it again to unlock. It only guards this page: your surveys, the settings and the API stay editable.

Export

downloads modules of this study as a JSON file. You pick the modules, and with Include survey items (ticked by default) each survey's items come along. The file also holds the study's header image, description, footer, public blurb, privacy policy, terms of service, automated actions, CSS, JS, R functions, Expires On and the names (not the values) of its R Secrets. The title, cookie lifetime, publicness and app settings stay behind.

Import

adds the modules from such a file, or from one of the instance's ready-made building blocks, after your last module. The positions that its skips and Waiting Times point at move along. Settings in the file replace this study's. R Secrets arrive as names without values, for you to fill in. A survey in the file is created in your account, unless you already have a survey of that name: then that survey gets the file's items, as if you had uploaded them (but if that would delete real participants' answers, formr refuses). If anything in the file can't be imported, formr says what and adds no modules. Surveys it had already imported by then stay, and the message names them.

I am panicking :-(

makes the study private, locks it and turns off its automated actions, all in one click. It's meant for when participants end up in the wrong place or too many emails go out. You undo each of the three by hand once things are fixed. Meanwhile participants see the service message, so say there what's going on.

Building blocks

Import offers these under Choose an existing complex building block. Each adds a few modules that you then adapt. The ones marked with a survey bring example surveys along, which are created in your account under the names given. In the others, you pick your own surveys.

  • Basic_Diary: an intake survey, an Email invitation every evening, a diary with time limits and a loop over 14 evenings (surveys example_diary_intake, example_diary). The diary guide explains it.
  • Experience_sampling: the same loop with Emails at random times between 9:00 and 21:00, about five a day (surveys example_esm_intake, example_esm). See Several prompts a day.
  • Reminder: a Waiting Time of an hour and a reminder Email, to put between an invitation and a survey.
  • Longitudinal_study: a first survey, a Pause of a year, an Email invitation and a second survey.
  • Filter: a Skip Forward and a Stop Point for those it screens out.
  • Simple_Social_Network: participants list their friends and then rate each one in a loop (surveys friend_list, friend_rate).
  • Text_message: an External link that sends a text message through a provider, with the token in an R Secret.
  • Data_Quality and Data_Quality_v2: consent, a Skip Forward for those who decline, and a short study with the data_quality and agent_probe items, as classic surveys (dq_weekend_consent, dq_weekend_study) or v2 forms (the same names with _v2).
  • Bot_Protection_v2: the same as v2 forms with bot_check and turnstile added (bp_weekend_consent, bp_weekend_study). It needs Turnstile set up on this instance.
  • Form_v2_Basic: a short v2 form (form_v2_basic) and a Stop Point.

If you already have a survey of one of these names, the import gives it the block's items, so rename yours first.

General

Title

the name of your study in the browser's tab, in link previews and on the Studies page. Without one, formr uses the study's name.

Header image

the address of an image shown at the top of every page of your study, and in link previews. You can put the image under Upload Files and paste its address here.

Expires On

the date on which formr deletes the data participants left in your study. See below.

Cookie/Session Lifetime

how long a participant's browser remembers them after their last visit, so they can come back without their personal link. 0 (the default for a new study) means as long as this instance keeps a session, a year unless its administrators changed it. You can't set a longer one. The lifetime only counts for participants who allowed functional cookies (formr asks in a bar at the bottom of the page, and the request_cookie item asks too). Everyone else is forgotten when their browser closes, and comes back through their personal link, e.g. {{login_link}} in an email. If participants share a computer, e.g. in the lab, use ?_new_session=1 or set a short lifetime. Generating an app manifest sets the lifetime to at least a year, or to the longest the instance allows.

Automated actions

lets formr move participants on while they're away: a Pause or Waiting Time ends on time, Emails and Push notifications go out, a survey whose time is up expires. Turned off, all of that only happens when the participant opens the study again. It's on for a new study. Turn it off when something seems to be going wrong and you need time to fix it.

Look & Feel

an old alternative style for surveys (Material Design) that we no longer maintain. A study that has it on can keep it, but once you turn it off, you can't turn it on again.

Description

Markdown shown at the top of every page of your study, and in link previews. Optional.

Imprint/Footer text

Markdown shown at the bottom of every page: who is responsible for the study and how participants can reach them. A new study's footer has your email address and links to its privacy policy, its terms of service and the participant's settings page, where they can unsubscribe from your emails. Change the contact if participants should write to someone else.

Public blurb

Markdown describing your study on the instance's Studies page, if it has one. It shows there only while Publicness is Link is public, everyone can access. Optional.

Expires On

On this date, formr deletes the data participants left in your study. Under the GDPR you have to delete personal data once you no longer need it for the purpose you collected it for. How long that is depends on your study, so you pick the date, up to a maximum that the settings page names (in months from today). A new study gets that maximum. If you didn't collect personal data, you don't have to delete anything. Bear in mind that answers which look anonymous can sometimes be combined with other data to identify someone. Where an instance sets no maximum, you may leave the date empty.

formr emails you reminders six months, two months, one month, one week and one day before the date, but never two within six days. On the date, formr deletes the data at its daily check once you have had at least two reminders and the first of them is at least two weeks old. Until then it reminds you instead. If you set a date only a few days ahead, the deletion waits until both are true.

What goes is every participant's data in the study, your test users' included: their user codes, where they were in the study and their answers to its surveys. The study itself stays, with its modules, surveys, settings and files. formr then makes the study private, turns off its automated actions, clears Expires On and emails you that it's done. The reminders' subject says the run "will be deleted", but only its data is.

formr first saves the results of each survey in an encrypted backup, which you can download for 30 days under Result backups in the study's menu, and then deletes the backups as well. If it can't write them, it deletes nothing, keeps the date and tries again the next day. The record of the emails your study sent, with each address, subject and text, also stays for 30 days, though you no longer see it. If you promised participants deletion by a certain date, set Expires On at least 30 days before it, and ask the people who run this instance how long they keep their own backups (see When your study expires).

To keep the data longer, move the date (as far as the maximum allows). A date that isn't after today is refused, and the old one stays. To keep a copy, download each survey's results before the date with Export Results (if the download fails, pick JSON), or use formr_api_fetch_results() from the formr R package, which keeps every participant's rows but, like the API, leaves out surveys whose results display you disabled and the user codes of unlinked ones (see the API tab).

Privacy

Your study's privacy policy and terms of service, written in Markdown. Participants can read them at privacy_policy/ and terms_of_service/ after your study's address, which a new study's footer links to. Left empty, those addresses lead to the study itself. A privacy policy and an imprint are required by law in some countries, and some instances don't let a study leave private without a privacy policy. There, removing the policy of a study that has left private makes it private again.

Privacy Policy

what data you collect, how you collect, store, use and protect it, and how participants can ask what you hold about them or ask you to delete it. The admin links a template at gdpr.eu.

Terms of Service

what participants may and may not do in your study.

CSS

Styles that apply to every page of your study. To style only some pages, use the classes on each page's content: .run_position_10 for the page at position 10, .run_unit_type_Survey for every classic survey, .run_unit_type_Endpage for every Stop Point (and the service message), .run_unit_type_Pause for a Pause. The pages of a v2 form don't carry these classes. Their body has the class fmr-form-v2-page instead. To style single items, give them classes in your survey sheet, see CSS classes.

JS

JavaScript that runs on every page of your study, e.g. to give participants hints as they type. It's a full programming language, so test it well.

On a v2 form, your script runs once, when all pages of the form are in the browser, and there is no jQuery ($). To act when a page is shown, listen for fmr:pagechange on document (in the solo layout it comes once per page, not per item). Scripts in labels with R don't run on v2. Use a note_iframe for such content.

A script can't load your study's own pages in the background (a fetch of the study's address, or an image or frame of it). Once the participant has started, formr answers that with an error (403), because loading a page moves them on as if they had opened it. Links with ?code= or ?_new_session=1 and the logout link also work only when the participant opens them. To go on, submit the page's form or send the participant to the address. A script that sends a page itself has to send the page's token along, as the field _formr_session_token or the header X-Formr-Session-Token (the page has it in window.formr.session_token).

Whether your scripts run at all depends on the instance. Where all studies share one web address, one study's script could read and change what its participants do in other studies, so an instance's administrators may restrict scripts. If they did, the JS tab says so, in one of two ways:

  • your study's own scripts run once a superadmin has approved the study (ask them), or
  • no study's own scripts run.

While your study's scripts are held back, nothing you wrote runs: not the JS tab, not <script> tags, event handlers such as onclick and javascript: links in your items and pages, not scripts among your uploaded files, and not htmlwidgets in knitr output on the page. formr's own scripts work. Showifs keep working as long as they stick to comparisons, arithmetic, the showif helpers and a few string methods. A showif beyond that isn't evaluated in the browser: in a classic survey its item stays as the server showed it, in a v2 form it stays hidden.

R Functions and R Secrets

R Functions

R functions and variables that all of your study's R code can call by name. Save & Test R Syntax checks them. See R Functions on the R Helpers tab.

R Secrets

values such as API keys that your R code reads as .formr$secret_<name>. They're stored encrypted and never shown again once saved. See R Secrets on the R Helpers tab.

</name>

App

Participants can add your study to their phone's home screen like an app (a progressive web app), and the study can then send them push notifications, e.g. for experience sampling. For that, the study needs an app manifest.

  1. Click Generate Manifest (the magic wand). formr writes a manifest from your study's name and description. It also sets the Cookie/Session Lifetime to at least a year (or the longest the instance allows), so that the app remembers its participant.
  2. If you have your own icons, upload them as a folder under Upload PWA Icon/Splash Screen Folder. Name them icon.png (the app's icon), apple-touch-icon.png (its icon on iPhones), screenshot_landscape.png and screenshot_portrait.png (shown when someone installs the study), and message.png and security.png (icons of the app's shortcuts). formr's own icon stands in for those the manifest needs and your folder lacks. The admin links a tool that makes them all from one image. A new folder replaces the old one, and the manifest is written anew.
  3. Edit the manifest if you like, and click Save Manifest Text. Do this last: uploading or clearing icons overwrites your changes.
  4. Add the progressive web app items (add_to_home_screen, push_notification, …) to a survey, and Push notification modules to the study.

Service message, Reminder and Overview

Service message

the page people see when your study's publicness doesn't let them in: everyone but you and test users while it's private, and newcomers while it's at You and people who already have an access code can access. Use it to say that the study is paused for repairs, or has ended. Each study starts with one that says "This study is currently being serviced. Please return at a later time."

Reminder

emails you send by hand, e.g. to participants who fall behind. Write them here, then send one from Users with the bullhorn button, to one participant or to all you selected. You can keep several.

Overview

a page of Markdown and R that only you see, under Overview in the study's menu, e.g. to count how many participants finished. Click Add Overview Script: the script it starts with draws how participants moved through the study, with formr_overview_sankey(). It reads your study through the API, so the study's owner needs API access (admin level 2, see the API tab).

Limits and alerts

Monthly compute limit

Your instance may limit how much computing time your studies use per calendar month. That's the time formr spends running your studies' modules, R on OpenCPU included, added up over all of your studies. Work that is repeated counts every time, e.g. a Pause whose condition is checked again and again. Your account page shows your Compute usage, and the page it links to lists each study's total, its average per session and its slowest session. There's no limit unless the instance's administrators set one.

When you reach the limit, formr makes every one of your studies private, turns off their automated actions and emails you. Nothing is deleted. formr doesn't reopen them for you: once you've cut down on what takes the time, or agreed on a higher limit with the administrators, set the publicness and turn Automated actions back on yourself. If you reopen them while you're still over the limit that month, formr closes them again.

When a module fails

If a module fails for a participant, formr emails you (subject "[formr] Run Notification"). That's R code that fails anywhere (a showif or value, a feedback page, a condition, a Pause, an External link, a Push notification), an Email without a valid address to go to, a jump to a position that doesn't exist, answers that couldn't be saved, and a step that formr can't run because of an error of its own ("formr could not run this step because of an error"). In that last case it tries again, less and less often, and the details are in the server's error log, so ask the people who run this instance. The email names the study, the module's position and type, the participant's user code and what went wrong. It comes from this formr instance's own address, not from one of your mail accounts, and you get at most 20 such emails a day. Emails that formr couldn't send for your study aren't among them. About those it emails you at most once a day for each mail account ("[formr] 3 emails were not sent from …"), and once when a mail account stops working ("[formr] Your mail account … is not working", see Sending emails).

You get one email per problem. If the same problem comes up again, e.g. for every participant who reaches the module, you hear about it again only after you have changed the module (saved it, or uploaded new items to its survey), with a count of how often it happened since. If OpenCPU doesn't answer, you get an email about that of its own, since changing your module won't fix it. Errors in test sessions only show on screen. Those that happen in the background, e.g. when a test session's Pause ends overnight, are emailed too. On a v2 form, a test session shows R's error where the label, choice or value is missing. Participants see no message there. A label or choice whose R fails stays empty, an item whose value fails gets none, and formr emails you.

Survey Spreadsheet


Survey spreadsheets contain the questions on a first sheet called "survey". They can optionally have a second sheet called "choices" where you define choices for multiple choice items in a long format. (If no sheet has that name, formr reads the second sheet as the choices when its first row has a list_name, name or label column. Otherwise it passes that sheet over and warns you if there's something on it.) They can also optionally have a third sheet called "settings" where you define settings such as pagination and validation (most set these settings after uploading the survey though). formr reads the settings sheet only when it creates a survey. Uploading new items to an existing survey leaves its settings as they are.

You can clone a Google spreadsheet to get started or start with an empty spreadsheet.

Some helpful tips:

  • You may want to make linebreaks in Excel to format your text. In Microsoft Excel on Macs, you need to press Command ⌘+Option ⌥+Enter ↩, on Windows it is Alt+Enter ↩. We suggest you start working from the provided sample sheet, because it already has the proper formatting and settings. In Google Spreadsheets, the combination is Option ⌥+Enter ↩.
  • Make text bold using __bold__, make it italic using *italic*.
type name label optional showif
text name Please enter your name *
number 1,130,1 age How old are you?
submit next Go on
mc agreement emotional_stability1R I worry a lot. age >= 18
mc agreement emotional_stability2R I easily get nervous and unsure of myself. age >= 18
mc agreement emotional_stability3 I am relaxed and not easily stressed. age >= 18
submit done Finish

A row of type submit ends a page. Here, age is asked on the first page, so the showifs on the second can use it.

Available columns

You can use more columns than the ones shown above. Unknown column types are simply ignored, so you can use them for other information. formr reads only the first 30 columns of the survey sheet, though, so put your own columns after formr's. If a column's name looks like a misspelt formr column (e.g. show_if or lable), formr warns you when you upload the sheet.

The following column types exist:

type
set the item type (see the item types tab). Some types take options after a space, e.g. number 1,130,1, or the name of a choice list, e.g. mc agreement.
type_options
the options of the item type, in a column of their own. formr reads type and type_options as if they were one cell, so number in type and 1,130,1 in type_options is the same as number 1,130,1 in type.
name
this is simply the name of the item. You'll use it to refer to the item in your data analysis and when making complex conditions, so adhere to a systematic naming scheme (we recommend scale1, scale2, scale3R for Likert-type items). A name has to start with a letter, can only contain letters (a to z, A to Z), the digits 0 to 9 and the underscore, and has to be 2 to 64 characters long. Two items can't share a name, even if the names differ only in upper and lower case. Some names are taken by formr's own columns in the results: session, session_id, id, study_id, iteration, created, modified, ended and expired. Don't use them for items. A v2 form reserves a few more.
label
This column is the text that will be shown on the left-hand side of the answer choices (for most items). You can use Markdown formatting here.
showif
a condition in R, e.g. sex == 1: the item is shown only when it's true. Leave it empty to always show the item. A condition on earlier pages or other surveys (other_survey$item_name != 2) can use any R. If it uses an answer on the same page, formr first checks it in R as the page opens, while that answer is still missing, and leaves it to the browser only when R can't decide. So write a plain comparison such as smoker == 1: !is.na(smoker), isTRUE(smoker == 1) or smoker %in% c(1, 2) leave the item off the page, unless the showif ends with //js_only. The browser knows only comparisons, &, |, ! and the %contains% helpers, and can't also use another survey (see Items on the same page). Test every condition. In a v2 form, showif is JavaScript instead (see the Form (v2) tab).
optional
Nearly all items are mandatory by default. By using * in this column, you can turn items optional instead. Using ! requires a response to items that are optional by default (e.g. check, check_button, mc_multiple, choose_two_weekdays). 1, true and yes work like *, and 0, false and no like !.
value
Sometimes you may want a value to be pre-set when users first fill out a form. This can be especially handy in longitudinal studies, where you want to check that e.g. contact information is still up-to-date or when you want to highlight changes across days. You can, again, use arbitrarily complex R code (e.g. a_different_survey$item1 + a_different_survey$item2) to pre-set a value, but you can also simply use 1 to choose the option with the value 1 (remember that choices for mc-family items are saved as numbers, not as the choice labels per default). There is one special word, sticky, which always pre-sets the item's value to the most recently chosen value. You also have to keep in mind when pre-setting strings, that they have to be marked up in R, like this "I am text" (preferably do not use single quotes because Excel will mess them up).
class
This column can optionally be added to visually style items. Find the available classes on the CSS classes tab.
choice1 - choice14
For multiple choice items, you can define the labels of the different choices here. In the database, the corresponding number will be stored (e.g. if choice1 is "honey", then the DB will record "1"). You can define at most 14 choices this way and you have no control over the value stored in the database. To define more than 14 choices or to reuse choice lists, use the choices sheet. The name and type columns have to come before (to the left of) the choice columns. An item either has its choices in these columns or names a choice list, not both.
choice_list
the name of a list on the choices sheet, for a multiple choice item. It does the same as writing the name after the type (mc agreement), so you need only one of the two. A rating_button is the exception: a name right after its type isn't a list, so use this column or write the list after the numbers (rating_button 1,5,1 agree). formr's own export of an item table writes this column and puts every item's choices on the choices sheet, so you can edit an export and upload it again.
item_order
By default (and if you leave this column empty), items in formr are simply displayed in the order they are defined in the spreadsheet. If you assign numbers here, those will define the order instead. If several items share the same number, their order will be randomised when the survey is loaded.
block_order
You can use 1-4 letters to define blocks. For consecutively labelled blocks (without gaps), formr will then randomise block-wise (e.g. an entire block of items comes either first or second). If it helps you think about it, you can imagine, the final order of items as being determined by sorting on block_number.item_number.random_number. If that didn't help enough, see the examples under "Randomising items and blocks" below.

Randomising items and blocks

Items with the same item_order are shuffled among themselves. Items with the same block_order form a block, and blocks that follow each other directly are shuffled as wholes. Four examples:

1. Simple randomisation of items

An instruction comes first, then items 1 to 4 in random order.

nameblock_orderitem_order
instr1
item_12
item_22
item_32
item_42

2. Random block order, fixed order within blocks

Blocks A and B come in random order. Inside each block, the items keep their order.

nameblock_orderitem_order
item_1A1
item_2A2
item_3B1
item_4B2

3. Fixed block order, random order within blocks

Blocks are only shuffled with their direct neighbours, so an item without a block_order between two blocks keeps them in place. Here the submit buttons have no block, so A always comes first. The items inside each block are shuffled, and each block gets its own page.

nameblock_orderitem_order
item_1A1
item_2A1
submit12
item_3B3
item_4B3
submit24

4. Random blocks, random items within them

Blocks are shuffled, and so are the items inside each block. Each submit button stays at the bottom of its page because it has the highest item_order in its block. The same trick keeps an instruction item at the top.

nameblock_orderitem_order
item_1A1
item_2A1
submit1A2
item_3B1
item_4B1
submit2B2

Optional classes for visual styling

Write class names in an item's class column, separated by spaces, to change how it looks. The CSS classes tab lists them. You can also use classes from your study's CSS (formr warns about these, in case of a typo).

Survey settings


A survey's settings decide how its pages work, who can see its results and how long participants have to fill it out. Open the survey in the admin (Surveys, then the survey). The settings are below Survey Shortcuts, and Save Settings saves them.

You can also give them in a sheet called settings in your spreadsheet, which formr reads when it creates the survey from it: one setting per row, its name in the first column and its value in the second. The API takes the same names (PATCH /v1/surveys/{name}, see the API tab). Each setting's name is given below.

Custom Paging, Survey Unlinking and Disable Results Display can't be turned off again once they're on, here or through the API.

Pages

Items Per Page

the most items a page shows, 0 (the default) for no limit. Without a limit, a page ends at the next submit item, which we prefer, because you decide where each page ends. Where formr cuts a page that has no submit item, it adds a button "Go on to the next page!". Not used with Custom Paging or on v2. Name: maximum_number_displayed.

Custom Paging

makes each submit item end a page, shows participants which page they're on ("Page 2/5"), and lets them go back to earlier pages with the Back to Page buttons. Items Per Page is ignored then. Not used on v2, where pages always end at submit items. Name: use_paging.

Enable Instant
Validation

tells participants that an answer is invalid as soon as they've entered it, not only when they try to go on. Not used on v2, which always flags a malformed answer when the participant leaves the field, and checks required items when they move on. Name: enable_instant_validation.

Percentage Display

the stretch of the progress bar this survey covers, 0 to 100 % by default. If two surveys follow each other, give the first 0 to 40 and the second 40 to 100, and the bar moves on steadily across both. Names: add_percentage_points (from) and displayed_percentage_maximum (to).

Who sees the results

Survey Unlinking

Unlinking keeps a survey's answers apart from everything else you know about a participant. Use it for identifying data that you only need to run the study, such as email addresses, so that they never sit in the same table as the answers you analyse. Name: unlinked.

Once a survey is unlinked, its results (Show Results, Export Results, the API) hold only the answers: no user codes, no session ids and no times, in random order. Until it has more than ten results from real participants (test users don't count), you only see your test users' answers. The same goes for one study's results, if several studies use the survey. Show Results doesn't filter if that would show or leave out ten or fewer. Someone you set to testing after they began stays a real participant here. Its Detailed Results stay empty, Export Run Data leaves it out, and neither Show Results nor the API gives you one participant's answers. Its result backups follow the same rules.

A study that has an unlinked survey, or one with Disable Results Display, doesn't show you its participants' email addresses either. formr puts *** in their place on Emails, on Users and User Details and in the exports of these two, and in its emails to you about an Email module that failed. This is for the whole study, because an email's time and position tell you whose address it was. It stays that way if you remove the survey from the study after participants have reached it.

Within your study, the answers are still linked to the participant, so your R code and Email modules can use them, e.g. to send each participant their invitations. Unlinking keeps you from linking the data by accident. It can't stop someone who sets out to link them with R code (formr runs whatever code you write).

Turn it on before anyone fills out the survey. Once on, it stays on.

Pos. 10. a survey called contact, unlinked, which asks for the participant's email address
(an item of type email).
Pos. 20. a survey called diary with the day's questions, with Start editing within and
Inactivity Expiration set (below).
Pos. 30. a pause until 6 pm the next day.
Pos. 40. an email to the participant, inviting them back with {{login_link}}.
Pos. 50. a skip backward to position 20, as long as nrow(diary) < 14.
Pos. 60. a stop point that thanks them.

What would happen? Participants give their email address once and then fill out the diary every evening for two weeks, invited by email. If you export contact, you get a list of email addresses in random order. If you export diary, you get the diary entries with user codes. Nothing in either tells you which address goes with which entries.

Disable Results Display

formr keeps storing the answers, but you can't see or download them. The survey's menu no longer offers Show Results or Export Results. Its Results button on your study's Edit Run page opens a page that only says how many participants began and completed it, Detailed Results give nothing, Export Run Data leaves the survey out, and the API returns none of its answers. Your study's R code and Email modules can still use them, e.g. to email a participant at the address they gave. The study's Emails page hides the addresses then (see above). Use it for data you need to run the study but never want to see. Once on, it stays on. Name: hide_results.

Deleting results and result backups

Before formr deletes the results of real participants, it saves them in a backup that you can download for 30 days. It does so when

  • you use Delete Results or Delete Study in a survey's menu. Both delete the survey's results in every study that uses it. Delete Results lists these studies with their numbers of rows before you confirm.
  • you upload new items that remove or re-type items participants have answered (see Changing a study while participants are in it).
  • you use Empty Run or Delete Run in a study's menu. They delete the results of that study only.
  • a study reaches its Expires On date.
  • you delete your account. Only the people who run this instance can read these backups.

The same deletions through the API are backed up, too. If a backup can't be written, formr deletes nothing and says so. One real participant is enough for a backup. Where a study has only test users' rows, they are deleted without one.

You find the backups under Result backups, in the survey's menu and in the study's, with the date, the reason and the number of rows. There's one for each survey and study, and it holds all the rows the survey had in that study, test users' included. If some answers weren't in the survey's results any more, e.g. those to an item you have removed, they're in a second backup. Each is a file of tab-separated text, as Export Results gives you with TSV. If you've deleted the survey, look on the study's page, and the other way round.

A download asks for your password (and your 2FA code, if you use 2FA), unless you logged in within the last 15 minutes. Only you can download your backups. There's no other way to get them on the web or through the API. The files are encrypted, and the people who run this instance can read them on the server. After 30 days formr deletes them (the instance can set another number of days, which the page names).

What you can't get from a backup:

  • A survey with Disable Results Display is backed up, but the backup has no download. That also holds for its backups from before you turned the setting on.
  • An unlinked survey's backup has no user codes, and its rows are in random order. If it has no more than ten rows from real participants, the download holds only your test users' rows. A backup from before you unlinked the survey has no download any more.
  • Files that participants uploaded are in no backup. formr deletes them in its nightly cleanup once the results are gone.
  • If you delete a single participant or a single entry (the bins in Users and User Details), nothing is backed up.

Deleted results are therefore still on the server for 30 days. The instance's backups of its whole database may keep them longer. Ask the people who run it for how long.

Time limits

A survey waits for its participant as long as it takes, unless you set a time limit. When a limit is up, the survey expires: the study moves the participant on to the next position, and the survey's results note the time in the expired column. A participant who still has the page open sees "Page expired", and what they hadn't sent in yet is lost.

Start editing within

minutes, counted from when the survey became available to the participant (e.g. when their invitation went out), within which they have to start. This is the access window. A participant who hasn't started by then is moved on. 0 (the default) means no limit. Name: expire_invitation_after.

finishing editing within

extra minutes after the access window closed, for participants who started in time. Then they have at most both together, counted from when the survey became available. 0 means no limit for those who started. Without an access window (Start editing within at 0), it has no effect, and the field is greyed out. Name: expire_invitation_grace.

Inactivity Expiration
(snooze)

minutes without activity after which a survey the participant started expires. Every answer they send in starts the count again. Much like with the snooze button on your alarm clock, a participant can keep it going indefinitely. 0 means no limit. Name: expire_after.

A participant has started once they've sent in an answer, e.g. submitted the first page (on v2, an answer saved as they type counts too). Opening the survey isn't enough. Before that, only Start editing within counts. After that, the survey expires at whichever comes first: the end of the access window plus the finishing time (if both are set), or the inactivity limit (if that's set). With neither, a participant who started can take as long as they like.

With Start editing within 60, finishing editing within 30 and Inactivity Expiration 20, this is what happens to three participants:

access window, 60 minutes finishing, 30 minutes Never starts ends after 60 Starts, then stops for too long ends after 40 Starts late, is not done in time ends after 90 0 20 40 60 80 90 minutes since thesurvey was available not started working on it no activity answers sent in survey ends
  • One never starts. They are moved on after 60 minutes, when the access window closes, also if they opened the survey but sent in nothing.
  • One starts, then stops for too long. They send in answers after 10 and after 20 minutes. After 40 minutes, they have been inactive for 20 and are moved on, although the access window is still open.
  • One starts late and isn't done in time. They start after 55 minutes and keep sending in answers. After 90 minutes (60 and 30), they are moved on all the same, and what they hadn't sent in is lost. Finishing before that would have been in time.

Two more examples, an invitation that's open for 7 hours in both:

  • Start editing within 420, finishing editing within 30, Inactivity Expiration 0. Nobody has more than 7.5 hours. Someone who never reacts is moved on after 7 hours. Someone who starts after 2.5 hours has 5 hours left. Someone who starts at 6:50 and takes their time is interrupted at 7:30, and if they open a page at 7:29 and send it at 7:31, that page is lost.
  • Start editing within 420, finishing editing within 0, Inactivity Expiration 30. Once people have started, they can take as long as they need, as long as they never leave the survey alone for half an hour. Someone who never reacts is moved on after 7 hours. Someone who sends in a first page at 6:50 and then leaves is moved on at 7:20. Someone who starts after one hour and then leaves is moved on at 1:30, although the access window is still open.

With Start editing within at 0, a participant who never starts stays at the survey until they do, and nothing after it in your study happens for them, whatever the other two settings say. Finishing editing within has no effect then, also for those who start. Only Inactivity Expiration counts.

The study moves participants on while they're away only if its Automated actions are on (see Study settings). Otherwise it happens the next time they open the study. The limits work the same way for v2 forms.

v2 settings

Once a survey runs on v2, its settings also offer Offline queue, Allow "Previous" button, Layout, Participant language, Button labels and a Compatibility scan. The box Survey engine: v1 or v2 below the settings moves a survey from one engine to the other. Both are explained on the Form (v2) tab.

Choices Spreadsheet


Choices sheets are fairly simple. The list_name column defines the choice set. By using that name in the type column of a multiple-choice item (or in its choice_list column), you assign that choice set. A list name can have letters, digits and underscores, up to 255 of them, and can't be 0. As you'd expect, the name column defines the value recorded in the database, the label defines what participants see by default. A name can be in a list only once. Names that differ only in upper and lower case count as two choices, and formr warns you about them. It is not currently possible to randomly order choice sets, except for rank items (e.g. rank fruits random). You can use Javascript to achieve this.

You can clone a Google spreadsheet to get started.

list_name name label
agreement 1 disagree completely
agreement 2 rather disagree
agreement 3 neither agree nor disagree
agreement 4 rather agree
agreement 5 agree completely

Survey Item Types


There are a lot of item types, in the beginning you will probably only need a few though. To see them in action, try using the following Google spreadsheet. It contains example uses of nearly every item there is.

Plain display types

note
display text. Notes are only displayed once, you can think of them as being "answered" simply by submitting.
note_iframe
If you want to render complex rmarkdown htmlwidgets, use this.
submit timeout | auto
display a submit button. No items are displayed after the submit button, until all of the ones preceding it have been answered. This is useful for pagination and to ensure that answers required for showif or for dynamically generating item text have been given.

You can specify an optional timeout/delay (in milliseconds).
Negative values mean that the user has to wait that long until they can click submit.
Positive values mean the submit button will automatically submit after that time has passed. However, if not all items are answered or optional, the user will end up on the same page and the timer will restart. To avoid that, you have to use it together with optional items. Then, it's a way to use timed submissions. The data in the item display table can be used to check how long an item was displayed and whether this matches with the server's time for when it sent the item and received the response (what its times mean).

You can also set the option to auto, which will cause the page to be submitted automatically as soon as all visible items on the page have been answered. Optional items count too, so the page waits for them as well. This can be used for e.g. creating menu-like pages.

Simple input family

text max_length
allows you to enter a text in a single-line input field. Adding a number text 100 defines the maximum number of characters that may be entered.
textarea max_length
displays a multi-line input field
tel
a single-line input for telephone numbers. Phones show their number keypad. Any format is accepted.
url
a single-line input for a web address. Both the browser and formr check that it is a URL.
cc
a single-line input for a credit card number. In a classic survey, the browser checks it with the Luhn checksum. A v2 form doesn't.
blank
shows the label as it is, without an input and without the styling of a note. Useful for your own markup, e.g. an <input> with the item's name. A classic survey counts a blank without one as done with its page. If a script makes the input only later (say when a task is over), leave the item required and put the script in the label or in the study's JavaScript, with the item's name in quotes. Then the page comes back until there's an answer. formr doesn't look into scripts that you load from another address.
number min, max, step
for numbers. Without options, the minimum is 0 and the maximum 10000000, so give a minimum for negative numbers (number -50,50). step defaults to 1 and can't be 0, using any will allow any decimals.
letters max_length
like text, allows only letters (A-Za-züäöß.;,!: ), no numbers.
email
for email addresses. formr checks that the text looks like an address, not that it exists or belongs to the participant. To be sure, send an email with {{login_link}} and go on only with those who open it.

Sliders

range min,max,step
these are sliders. The numeric value chosen is not displayed. The text shown to the left and right of the slider is defined using the choice1 and choice2 fields. A slider without them is refused when you upload the sheet. Defaults are 0,100,1. The step can't be 0.
range_ticks min,max,step
like range but the individual steps are visually indicated using ticks (at most 10000). A classic survey shows the chosen number to the right, a v2 form doesn't.
visual_analog_scale min,max,step
like range, but without a starting position. The slider's handle stays hidden until the participant clicks or drags it, and until then the item is empty (not the midpoint), so a required one can't be skipped. The end labels come from choice1 and choice2 and are required, as for range. Defaults are 0,100,1. Works in classic surveys and v2 forms.

Datetime family

date min,max
for dates (displays a date picker). Input can be constrained using the min,max parameters. Allowed values would e.g. be 2013-01-01,2014-01-01 or -2years,now.
time min,max
for times (displays an input with hours and minutes). Input can also be constrained using min,max, e.g. 12:00,17:00. The answer comes as text: 14:30:00 in results, exports and R, which strptime(x, "%H:%M:%S") reads. The API and Export Run Data give 14:30.
datetime_local min,max
a date and a time in one input, using the browser's own control. The answer comes as text: 2024-05-01 14:30:00 in results, exports and R, which as.POSIXct() reads. The API and Export Run Data give the browser's format, 2024-05-01T14:30, which R reads as midnight unless you say as.POSIXct(x, format = "%Y-%m-%dT%H:%M").
datetime min,max
like datetime_local, kept for older sheets. Browsers no longer have a control for it, so use datetime_local.
yearmonth min,max
a year and a month, entered as yyyy-mm. Stored as the first day of that month (2024-05-01).
month min,max
like yearmonth, but with the browser's month picker where it has one.
week min,max
an ISO week, entered as yyyy-Www (e.g. 2024-W05) and stored as text.
year min,max
a four-digit year between 1901 and 2155.

Fancy family

geopoint
displays a button next to a text field. If you press the button (which has the location icon on it) and agree to share your location, the GPS coordinates will be saved. If you deny access or if GPS positioning fails, you can enter a location manually.
color
allows you to pick a colour, using the operating system's colour picker

Multiple choice family

These items let participants choose from a list. You define the choices in the columns choice1, choice2, … or on the choices sheet (see Survey Spreadsheet). Most store the choice's name, not its label: 1 for choice1, or the name from your choices sheet. So write demographics$sex == 1 in a condition, not demographics$sex == 'male'. Items that take several answers store them in one text, e.g. 1, 4, 7 (see Multiple choices). select_or_add_one, select_or_add_multiple and timezone store text instead: the label, or what the participant typed (see each entry below).

mc choice_list
multiple choice (radio buttons), you can choose only one.
mc_button choice_list
like mc but instead of the text appearing next to a small button, a big button contains each choice label
mc_multiple choice_list
multiple multiple choice (check boxes), you can choose several.
mc_multiple_button
like mc_multiple and mc_button
check
a single check box for confirmation of a statement.
check_button
a bigger button to check.
rating_button
min, max, step
This shows the choice1 label to the left, the choice2 label to the right and a series of numbered buttons as defined by min,max,step in between. Defaults to 1,5,1. A single number sets the maximum: rating_button 7 shows buttons 1 to 7. Separate the numbers with commas (rating_button 1 7 shows a single button). Without options, or with a blank cell in a type_options column, it shows 1 to 5. Other words are refused when you upload the sheet, and so is a step of 0 or one larger than the range.
sex
shorthand for mc_button with the ♂, ♀ symbols as choices
select_one choice_list
a dropdown, you can choose only one
timezone
a dropdown of all time zones. It preselects the participant's own zone in most browsers, so keep it required and ask them to check it. It needs no choice list. The answer is stored as text, with spaces around the slash and in place of underscores: Europe - Berlin for Europe/Berlin, America - New York for America/New_York.
select_multiple choice_list
a list in which you can choose several options
select_or_add_one
choice_list, maxType
like select_one, but it allows users to choose an option not given. Uses Select2 (Tom Select in a v2 form). maxType can be used to set an upper limit on the length of the user-added option. Defaults to 255.
select_or_add_multiple
choice_list, maxType,
maxChoose
like select_multiple and select_or_add_one, allows users to add options not given. maxChoose can be used to place an upper limit on the number of chooseable options. In a v2 form, the answers are stored separated by semicolons (Berlin, Germany;Paris, split them with strsplit(x, ";") in R), so a choice can't contain a semicolon. A classic survey separates them with commas. You can also write the whole choice list of either select_or_add type in one cell, separated the same way: red;green;blue in v2, red,green,blue in a classic survey.
rank
choice_list, random, touch
participants put all the choices in order, as in Qualtrics, by dragging the rows, with the ▲/▼ buttons or with the keyboard (arrow keys, Home, End). The answer is the choice names in that order, separated by commas: 3, 1, 2 means choice 3 came first, and strsplit(rank, ", ") in R gives you the ranking.
random (or shuffle) after the choice list shuffles the starting order, so an untouched list doesn't store your order. With touch (or require_change), the item counts as answered only once the participant has moved or tapped something. Without it, submitting stores the order as shown. Example: rank fruits random touch.
A partial or repeated order is refused, and only an optional item can be left unranked. When the item is shown again, it starts from the earlier answer (or from its value).
v2 forms only. A classic survey refuses the item at upload.
mc_heading choice_list
This type permits you to show the labels for mc or mc_multiple choices only once.
To get the necessary tabular look, assign a constant width to the choices (using e.g. mc_width100), give the heading the same choices as the mcs, and give the following mcs (or mc_multiples) the same classes + hide_label.
On small screens the mc_heading will be hidden and labels will automatically be displayed again, because the tabular layout would otherwise break down.
Classic surveys only. A v2 form leaves the row out, and each item below it shows its own choice labels, also with hide_label. Put a heading that participants need to read in a note.

Bot check

The bot_check item makes automated submissions more costly. The participant's browser has to solve a small puzzle, made and checked on your own formr server. Nothing about the participant goes anywhere else, so unlike a hosted captcha it adds no third party to your data processing agreement. It makes scripted mass responding expensive, but anyone who fills out your survey by hand passes it, paid or not.

bot_check
shows a checkbox ("I'm not a robot"). Ticking it starts the puzzle, which usually takes about a second, and the page can't be submitted before it has worked. An optional item can be left unticked (it then stays empty), but a failed puzzle still blocks the page. bot_check 2 or bot_check 3 makes the puzzle two or three times the work. Without a number, the instance's setting applies.
formr stores only the word verified, nothing that identifies the participant.
The label is the prompt above the box, choice1 the text next to it, choice2 the text once it's verified and choice3 the text while it works. Leave them empty for the English defaults. With choice1 = I confirm I am completing this survey myself, without automation. participants also confirm that they answer themselves.
v2 forms only. A classic survey refuses the item at upload.

The turnstile item asks Cloudflare Turnstile, a hosted bot detection service, what it thinks of the participant, and stores the verdict. Unlike bot_check, it sends data about the participant to a third party (see the data protection notes below). That's why it is only available where the administrator of your formr instance has set it up. On this instance: invisible, non_interactive, managed. A survey that uses a mode the instance has no keys for is refused at upload. If the keys are removed later, the survey's admin pages say so in red. Until they are back, those items store unavailable, and a required turnstile managed lets every participant through.

turnstile
runs Cloudflare's Invisible widget when the item's page is shown. The participant sees nothing and does nothing. The verdict is stored with the page, and the item never blocks a page.
turnstile non_interactive
Cloudflare's Non-interactive widget, which also only records. With turnstile non_interactive visible, participants see Cloudflare's small box with a spinner and its logo while it checks.
turnstile managed
a gate. Cloudflare's box is shown, and the page can't be sent until Cloudflare has passed the participant. If Cloudflare is unsure, it asks for a click on a checkbox, so a person it doubts can still get through. If formr can't reach Cloudflare at all, the page goes through and unavailable is stored, so an outage at Cloudflare doesn't close your study. An optional managed item only records.
stored values
pass Cloudflare passed the participant, on this study's domain. This is the only value that is evidence of anything.
rejected Cloudflare refused the check's token, or what the page sent was not a verdict formr had signed.
expired the token reached formr too late or a second time.
bot:600010 (or another 300xxx or 600xxx code) Cloudflare's check failed in the browser: Cloudflare's own words are "bot behaviour detected". Browsers driven by software are flagged this way.
error:110200 (or another code) the widget had another problem, such as a configuration, clock or network error.
blocked Cloudflare's script did not load, usually because of a content blocker or privacy extension.
pending the page was sent before the check had finished.
no_token nothing came back: no JavaScript ran.
unavailable formr could not ask Cloudflare.
skipped in "Test Survey": the preview asks Cloudflare nothing, and a gate lets it through.
test the instance uses Cloudflare's test keys, which pass everyone: for trying the item out, never for a study.
Everything but pass means "not verified", with a reason. Values that come from the browser (bot, error, blocked, pending) are what the browser reported. A pass can't be faked that way.
Once a verdict is stored, it stays. Cloudflare is not asked again when the page is sent a second time. v2 forms only. A classic survey refuses the item at upload.
Data protection with turnstile
  • Cloudflare is a third party. When the item's page is shown, the participant's browser loads Cloudflare's script from challenges.cloudflare.com and sends Cloudflare their IP address, the browser's TLS fingerprint and User-Agent, and further signals about the browser and device. formr itself sends Cloudflare only the check's token, not the IP address.
  • Cloudflare doesn't only act on your behalf. It processes these signals to detect bots for this site and, according to its Turnstile privacy notice, also as a controller in its own right to improve Turnstile. Participants have to be told.
  • The data go to the United States. Cloudflare, Inc. is a US company. The keys belong to the Cloudflare account of whoever runs this formr instance. Ask them which data processing agreement covers it, and involve your data protection officer and, where it applies, your ethics committee.
  • Ask for consent first. Reading information from a participant's device requires their consent in the EU (Art. 5(3) ePrivacy Directive, in Germany § 25 TDDDG). Put the item on a page after your consent page, and make sure people who decline never reach that page. Cloudflare's script loads only when the item's page is shown, never earlier in the form.
  • A gate makes Cloudflare a condition of taking part. That strains "freely given" consent (Art. 7(4) GDPR), and it stops people whose privacy tools block Cloudflare. Say so before consent, and use the recording modes unless fraud makes the gate worth it.
  • Say what you will do with the verdict. Don't exclude participants on it unless your consent text and preregistration say so. It is a black box, and it is not neutral: privacy tools, VPNs, Tor and older browsers produce blocked and bot more often.
  • Name Cloudflare as a recipient in your study's privacy policy.

A sentence for your consent text: "To detect automated responses, this survey uses Cloudflare Turnstile, a service of Cloudflare, Inc. (USA). On the page where it runs, your browser sends Cloudflare your IP address and technical information about your browser and device. Cloudflare uses this information to assess whether you are a person or a program, and also to improve its service. We store only its result."

Two more item types, data_quality and agent_probe, record signs of automated or careless responding without blocking anyone. The admin documentation describes them (you need to be logged in).

Hidden family

These items don't require the user to do anything, so including them simply means that the relevant value will be stored. If a survey has nothing but such items, things will wrap up immediately and move to the next element in the study (a v2 form with a hidden item does so once the participant opens it). This can be useful for hooking up with other software which sends data over the query string, e.g. https://study.researchmixtape.com/run_name/?param1=10&user_id=29

calculate
in the value column you can specify an R expression, the result of which will be saved into this variable. Useful to pull in external data or to forestall recalculating something repeatedly that you want to refer to later. If the calculation is based on values from the same module, you can insert the calculate item in the last line of the sheet behind the last submit button and its result will be stored in the database for use in further modules.
Classic surveys only. v2 forms have no calculate item, so a survey with one can't be moved to v2. Use a hidden item with the same value if the survey needs the result, or compute it in the R code of the module that uses it.
ip
saves your IP address. You should probably not do this covertly but explicitly announce it. If formr runs behind a proxy, the web server has to pass the participant's address on (mod_remoteip). Otherwise you store the proxy's address.
referrer
saves the last outside referrer (if any), i.e. from which website you came to formr
server var
saves the $_SERVER value with the index given by var. Can be used to store one of 'HTTP_USER_AGENT', 'HTTP_ACCEPT', 'HTTP_ACCEPT_CHARSET', 'HTTP_ACCEPT_ENCODING', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_CONNECTION', 'HTTP_HOST', 'QUERY_STRING', 'REQUEST_TIME', 'REQUEST_TIME_FLOAT', 'HTTP_SEC_CH_UA', 'HTTP_SEC_CH_UA_MOBILE', 'HTTP_SEC_CH_UA_PLATFORM', 'HTTP_SIGNATURE_AGENT', 'HTTP_SIGNATURE_INPUT', 'HTTP_SIGNATURE'. In English: the browser, some stuff about browser language information, some server stuff, access time, what Chrome-like browsers say about themselves beside the user-agent string (their name and version, mobile or not, their operating system), and the signature with which an AI agent that identifies itself signs its requests.
browser
saves the participant's user-agent string. Same as server HTTP_USER_AGENT.
get var
saves the var from the query string, so in the example above get param1 would lead to 10 being stored. In a classic survey, put it on the first page, because later pages are opened without the parameter. A v2 form stores it when participants first open the form, whichever page it's on.
A few parameter names are formr's own, so don't use them for your data. code carries the participant's user code (if it holds anything else, participants see "Invalid user code"), and formr also uses run_name, route, _new_session, _pwa and _fp.
random min,max
generates a random number for later use (e.g. randomisation in experiments). Minimum and maximum default to 0 and 1 respectively. If you specify them, you have to specify both, the lower number first.
hidden
you can use this item with a pre-set value, if you need to use data from previous pages together with data on the same page for a showif
block
Blocks progress. You can give this item a showif such as (item1 + item2) > 100 to add further requirements.

File uploads

You can ask study participants to upload image, audio, video, text, and PDF files in formr. Server-side limits for the maximal file sizes apply, you can also set lower limits per item. The number after the type is that limit in megabytes, e.g. image 2, or file 0.5 for half a megabyte.

file max_size_in_megabytes
Permits all of the file types allowed by audio, video, image plus PDFs and some text files.
audio max_size_in_megabytes
Upload audio files. If you assign the class "record_audio" in the class column, a little recording interface will be shown. It will use the device microphone.
video max_size_in_megabytes
Upload video files.
image max_size_in_megabytes
Upload image files. On smartphones, this can trigger the camera app.

Progressive web app items

formr studies can be installed as a PWA (Progressive Web App). This allows you to send push notifications to users to invite them to return to the study, e.g. for experience sampling studies. To make this work, you need to generate a manifest.json file in the study's settings.

request_phone
Helps transition desktop users to continue the study on their mobile device. On mobile devices, it automatically confirms mobile usage. On desktop, it displays a QR code for users to scan with their phone. Returns 'is_phone' for mobile users, 'is_desktop' for desktop users, or 'not_checked' before verification.
add_to_home_screen
shows a button that asks participants to add the study to their home screen. You can change the button's text in choice1. The item stores how far they got:
on the home screen: installed (classic, the page was opened from there or the browser's install dialog succeeded), added or already_added (v2)
the install dialog was shown: prompted
nothing has come of it yet: not_started (classic), not_requested (v2, the button hasn't been used)
said no, or it failed: declined or failed (classic), not_added (v2)
the browser can't add it: no_support or unsupported_browser, and in v2 not_prompted (the browser offered no install prompt)
push_notification
shows a button that asks participants to allow push notifications. You can change its text in choice1. If they allow them, the item stores what formr needs to send them notifications. If not, it stores why:
not_requested not asked yet
ios_install_required on an iPhone or iPad, the study has to be added to the home screen first (a v2 form stores not_supported here)
ios_version_not_supported iOS before 16.4 (a v2 form stores not_supported here too)
expired: followed by a code (plain expired in answers that older formr versions stored): the push service told formr that the subscription is gone. Test for it with startsWith(x, "expired"). A classic survey's own results, exports and R aren't updated when this happens, nor when a participant later turns notifications off, and keep showing the subscription, so use a v2 form if your study sends notifications. The API shows the current state for both.
permission_denied, not_supported, no_service_worker, no_subscription, invalid_config or error
A required item is answered only when the participant allows notifications.
request_cookie
asks participants to allow functional cookies, so that formr recognises their device when they come back. Where they have already allowed them, it shows nothing. It stores functional_cookie if they had agreed before, consent_given after they use the button, and not_checked until then. A required item keeps the page from being submitted until they agree. A study on the home screen usually needs these cookies to recognise participants from one visit to the next, so this item fits right after add_to_home_screen.

CSS classes


You might want to tinker with the look of certain form items. To do so you can use a variety of pre-set CSS classes. This is a fancy way of saying that if you make a new column in your survey sheet, call it "class" and add space-separated magic words, stuff will look different.

All classes are defined in custom_item_classes.css on GitHub. If you find one there that isn't described below, the file is the full list. Every item also has the class item-<type> (for example item-mc), so you can style all items of one type at once. If the pre-set classes aren't enough, add your own CSS in your study's settings (the CSS tab). formr loads it on every page of your study. Put your own class names in the class column and style them there.

To style only some pages of your study, start your selector with the page's position or module type. Each page carries both, e.g. run_position_10 for the module at position 10, and run_unit_type_Survey for a classic survey or run_unit_type_Endpage for a stop point. .run_position_10 .item-mc label { font-size: 1.2em; } changes only the mc items at position 10. Pages of a v2 form don't carry these classes.

When you upload a sheet with a class formr doesn't know, it warns you that you "used CSS classes that aren't part of the standard set". That's expected for your own classes. One class below (counter) gets the warning too, and works anyway.

These are the available styling classes:

left100, (200, …, 900)
controls the width of the left-hand column (labels). The default is left300, you have 100 pixel increments to choose from. left50 makes it 50 pixels wide, and left0 hides the labels.
right100, (200, …, 900)
controls the width of the right-hand column (answers). There is no default here, usually the right-hand column will extend in accordance with the display width. For short answers such as a number, there are also right20, right30, right50, right70, right80 and right150.
right_offset0, (100, …, 900)
controls the offset (distance) of the right-hand column to the left (not the label column, just the left). This is 300 pixels (+20 extra) by default. Analogously with left_offset100 etc. (defaults to 0).
padding100, (200, …, 900)
indents both the label and the answer by that many pixels.
label_align_left
label_align_center
label_align_right
controls the text alignment of the left-hand column (labels), by default it is aligned to the right.
answer_align_left
answer_align_center
answer_align_right
controls the text alignment of the right-hand column (answers), by default it is aligned to the left.
answer_below_label
This leads to answers stacking below labels, instead of them being side-by-side (the default). It entails zero offsets and left alignment. Can be overridden with offsets and the alignment classes.
align_horizontally
puts the item next to the one before it instead of below it, and hides its label. Give several items in a row this class to line them up, e.g. the name, age and relationship of one person in a social network questionnaire. The next item without the class starts a new line. On small screens, the items stack as usual and show their labels.
clear
starts the item on a new line, below anything floating beside it. Use it on the first item of each row of align_horizontally items, and on the item after an image you floated with float_image_left or float_image_right.
row_height_40
makes the item 40 pixels high (except on small screens), so that rows of align_horizontally items line up.
label_as_placeholder
also shows the label inside the empty input field, in grey, until the participant types. Useful together with align_horizontally, which hides the label.
hide_label
This hides the labels for mc and mc_multiple replies. Useful in combination with a fixed width for mc, mc_multiple labels and mc_heading. This way you can achieve a tabular layout. On small screens labels will automatically be displayed again, because the tabular layout cannot be maintained then. Classic surveys only. On v2 forms, which have no heading row, the labels always show, and on a wide screen the choices are as wide as their labels (mc_width… has no effect there).
show_value_instead_of_label
This hides the labels for mc_button and mc_multiple_button, instead it shows their values (the names of the choices, e.g. 1 to 5). Useful in combination with mc_heading. This way you can achieve a tabular layout. On small screens labels will automatically be displayed again, because the tabular layout cannot be maintained then. On v2 forms, which show no mc_heading, explain the values in a note.
blank_button
hides the text on the buttons of mc_button, mc_multiple_button and rating_button items (on a rating_button, the numbers), but keeps the buttons their size.
rotate_label45, rotate_label30,
rotate_label90
This rotates the labels for mc and mc_multiple replies. Useful if some have long words, that would lead to exaggerated widths for one answer column.
mc_block
This turns answer labels for mc-family items into blocks, so that lines break before and after the label.
mc_vertical
This makes answer labels for mc-family items stack up. Useful if you have so many options, that they jut out of the viewport. If you have very long list, consider using select-type items instead (they come with a search function).
mc_horizontal
This makes answer labels for mc-family items stay horizontal on small screens.
mc_equal_widths
This makes answer labels for mc-family items have equal widths, even though their contents would lead them to have different widths. This won't work in combination with every other option for mc-styling and if your widest elements are very wide, the choices might jut out of the viewport.
mc_width50 (60, 70, 80,
90, 100, 150, 200)
This makes choice labels and choice buttons for mc-family items have fixed widths, in pixels. Classic surveys have no mc_width90, and mc_width80 gives 90 pixels there (80 on v2 forms). If one choice has text wider than that width, it might jut out or ignore the fixed width, depending on the browser.
mc_boxed
draws thin light grey lines between the choices of mc and mc_multiple items (not before the first or after the last). Together with hide_label and an mc_width class, it makes a matrix of mc items look like a table.
rating_button_label_width50
(60, 70, 80, 90, 100, 150, 200)
This makes the labels for rating_button items have fixed widths. This can be useful to align rating_button buttons with each other even though the end points are labelled differently. A more flexible solution would be to horizontally centre the choices using answer_align_center.
square
(square60, 70, 80, 100)
turns the buttons of mc_button, mc_multiple_button and rating_button items into separate squares of 50 pixels with a gap between them, which wrap onto the next line when they run out of space. Add square60, square70, square80 or square100 for bigger squares, e.g. square square80. In classic surveys, square70 gives 60 pixels.
analogue_rating_scale
(15, 25, 30)
turns the buttons of a rating_button item into a row of small grey boxes without numbers, so that the scale looks like a line divided into steps. The chosen box turns darker. The boxes are 20 pixels wide. Add analogue_rating_scale15, analogue_rating_scale25 or analogue_rating_scale30 to make them 15, 25 or 30 pixels wide (on small screens, unless you add mc_horizontal, these set the boxes' height instead). Participants click a box. They can't drag along the line as on a slider. If you want a slider without a starting position, use the visual_analog_scale item type.
space_bottom_10
(20, 30, 40, 50, 60)
Controls the space after an item, in pixels. Classic surveys have no space_bottom_40, and space_bottom_50 gives 40 pixels there. The default is 15 pixels in classic surveys and none on v2 forms.
space_label_answer_vertical_10
(10, 20, … , 60)
Controls the vertical space between label and choices, if you've set answer_below_label. Default value is 15.
thick_border_top
draws a grey line, 2 pixels thick, above the item, e.g. to separate groups of questions.
float_image_left
float_image_right
moves the images in the item to the left or right, so that the text flows around them.
hidden
hides the item from participants. Its value is still sent with the page, so you can use it for an item that gets its value from the value column or from your own JavaScript. Make such an item optional, because participants can't answer what they can't see. If the item has a showif, the showif decides: when it is true, the item is shown.
clickable_map
If you use this class for a text type item, with one image in the label, this image will become a clickable image, with the four outer corners selectable (the selection will be stored in the text field). Will probably require customisation for your purposes. Classic surveys only.
people_list
turns a textarea item into a list of names, e.g. for a social network questionnaire. Participants type a name and press Enter to add it, up to 15 names of up to 50 characters each. The answer is stored with one name per line. Its prompts are in German. Classic surveys only.
counter
replaces the field of a number item with a button to count down and one to count up. Classic surveys only. A v2 form shows the number field.
vertical_range
shows the slider of a range or range_ticks item upright, 140 pixels high, with its end labels above and below it. Classic surveys only.

Form (v2)


v2 is formr's newer survey engine. A survey that runs on it is a v2 form. It sits in your study as a Form module and doesn't reload between pages. You choose the engine per survey, and the classic engine (v1) works as before.

The one authoring rule that changes: in v2, showif is JavaScript and runs in the participant's browser. R goes into value, and a hidden item's value is how an R result gets into a showif. The item table, the item types and R elsewhere in your study stay as they were, except that v2 doesn't run calculate items. See showif and value.

What changes

For your participants:

  • There is no reload between pages. Your submit items still end each page.
  • Follow-up questions appear and disappear the moment an answer changes.
  • Answers are saved as they go, so you keep what someone answered before they stopped.
  • A page sent without a connection waits on their device until they are back online.
  • There is a one-item-per-screen layout for phones.

For you, item names, results and exports stay the same, apart from a few differences. You have to rewrite showifs that contain R and replace calculate items.

v2 is new (the admin marks it as beta), so test a v2 form yourself before participants see it. For a survey that is already collecting data, go through the upgrade checklist.

An example

Pos. 10. a survey called demographics that asks for the participant's age.
Pos. 20. a v2 form called diary, one page with these items:

nametypeshowifvalue
olderhiddenifelse(demographics$age >= 30, 1, 0)
moodmc mood_scale (choices 1 to 5)
mood_whytextareaanswered(mood) && mood <= 2
back_painmc yes_noolder == 1
donesubmit

Pos. 30. a stop point.

What would happen? When a participant who finished demographics reaches diary, formr computes older from their age, so only participants aged 30 or older see back_pain. mood_why stays hidden until they pick a mood (that's what answered(mood) is for). If they pick 1 or 2, it appears at once. If they change it to 4, it disappears, and what they typed there is not stored. Each answer is saved within about 20 seconds. If their train enters a tunnel as they tap the button, the page waits on their phone and is sent when the connection is back. Then they see the stop point.

Putting a survey on v2

A new survey is on v1 unless you choose v2. You add a v2 form to your study like any other survey, with Add Survey (the list marks it (v2)). There are three ways onto v2, none of which changes your items. All three need v2 to be enabled on your formr server:

Upload it on v2
When you upload a survey (Surveys → Create new Survey), set Engine to v2. You only see this choice if the administrator of your formr server has enabled v2. A survey you exported from formr remembers its engine.
Move an existing survey
On the survey's settings page, the box Survey engine: v1 or v2 has Move to v2. It is refused while any study runs it as a classic survey (upload a copy instead), while the survey has items v2 can't run, and while the compatibility check flags something. If the check is wrong, its page offers Move to v2 anyway.
Import the example
Import on a study's Edit Run page offers Form_v2_Basic among its building blocks: a short v2 form (with a rank, a visual_analog_scale and a bot_check) and a Stop Point. Export with Include survey items takes your own surveys along the same way, engine included.

Switch back to v1, in the same box, puts the survey on v1 for every study that shows it. Participants in the middle of it keep their answers. It is refused while the survey has items only v2 can run (rank, bot_check, turnstile).

Once a survey is on v2, its settings page has a section v2 settings:

SettingDefaultWhat it does
Offline queue (Enable offline queue)onKeeps a page sent without a connection on the participant's device until it can be sent. Turn it off if answers must not be stored on participants' devices, even briefly. They then see an error instead.
Allow "Previous" button (Show "Previous" button)offLets participants go back to earlier pages. While it's off, the browser's back button doesn't take them back either.
LayoutDefaultDefault or Solo, see Layouts.
Participant languageenA language code such as en, de or de-AT. formr's own texts (buttons, messages) come in English and German, otherwise in English. Right-to-left languages such as Arabic get a right-to-left page. Your labels aren't translated.
Button labelsemptyYour wording for the Next button and the last page's button, up to 100 characters. A submit item without a label uses it too.

Three classic settings do nothing on v2: Items Per Page and Custom Paging (pages always end at submit items), and Enable Instant Validation (v2 always flags a malformed answer when the participant leaves the field, and checks required items when they move on).

showif and value

In v2, the two columns follow two rules:

  1. showif is JavaScript. It runs in the participant's browser, again whenever an answer changes.
  2. value is R. Anything other than an empty cell or a number runs in R on the server.
Writing a showif

Every item of the survey can be used by its name, so mood == 3 or age >= 18 && consent == 1 work as they are. Comparisons with <, <= and != need answered() in front (see Unanswered items). R in a v1 showif has to be rewritten:

v1 (R)v2 (JavaScript)
current(x), tail(x, 1)x
TRUE, FALSEtrue, false
x %in% c(1, 2)x == 1 || x == 2
ifelse(a, b, c)a ? b : c
is.na(x)isNA(x)
x < 3, x != 1 (hidden while x is unanswered)answered(x) && x < 3, answered(x) && x != 1
x %contains% "a"contains(x, "a")
x %contains_word% "a"containsWord(x, "a")
x %begins_with% "a", x %starts_with% "a"startsWith(x, "a")
x %ends_with% "a"endsWith(x, "a")
HelperWhat it does
isNA(x)true if x is unanswered. 0 is an answer.
answered(x)the opposite of isNA(x)
contains(x, a)whether a was ticked in a multiple-choice item, or is part of a text
containsWord(x, a)whether the text contains a as a whole word
startsWith(x, a), endsWith(x, a)whether the text begins or ends with a
last(x)the last of several selected values, or the one value

& and | between comparisons, as in a == 1 & b == 2, work in both. In a new showif, write && and ||, and use them wherever one side isn't a comparison: between numbers, & and | compare bit by bit.

An answer that looks like a number is a number (age > 17 needs no quotes), and other answers are text. mc_multiple and select_multiple hold a list of the ticked values, so write contains(pets, 2), not pets == 2. An unticked check is 0. The answer of an item a showif hides doesn't count, so showifs that depend on it react too.

showif: mood == 3
showif: answered(mood) && mood <= 2
showif: trigger == "yes" && answered(plain)
showif: contains(animals, 1)
showif: last(daily_mood) > 5

An unanswered item is null, and JavaScript compares null like 0. So mood <= 2, mood < 3 and smoker != 1 are true before the participant has answered, and so is !contains(animals, 1). In R they were NA, and the item stayed hidden. Where an item should wait for the answer, start its showif with answered(): answered(mood) && mood <= 2. mood == 3 and age >= 18 need nothing, because null equals no number and isn't greater than a positive one.

Only the browser runs showifs. An item with a showif starts out hidden and appears once its showif is true. The browser knows every item of this survey, answers from earlier pages included, but nothing else. A showif that uses ran_group or another survey's item fails, and its item stays hidden. Bring such values in with a hidden item.

Where your formr server's administrator has switched off authors' own scripts, showifs can only use operators, ? :, .length, common text and list methods, Math and the helpers.

Writing a value

An empty cell or a number is a plain default. Anything else is R, run on the server with the participant's answers so far, so sticky keeps its meaning:

value: 5
value: sticky
value: sample(1:2, 1)

The last one draws a random group, 1 or 2.

formr runs a page's R (values, and labels or choices with R in them) when the participant reaches the page, so a value on page 2 can use answers from page 1. On the first page, R content may appear a moment after the rest. A result is reused for 5 minutes while the answers stay the same. The R code never reaches the browser, and a value never overwrites an answer already given. As elsewhere, R sees the items your code names. A function on your R Functions tab that reads diary$mood itself has to be called from code that names mood, too.

If a value's R fails, the item gets no value, and formr tries again the next time the page is shown. A label or choice whose R fails stays empty, and a note_iframe says "This content is temporarily unavailable." Participants see no message about the R, and formr emails you ("[formr] Run Notification"). Your test users (Test Run, Test Survey) see R's error in its place, and you get no email about them.

calculate items

v2 runs R only for what a page shows. A survey with a calculate item, or another item that takes no input but has R in value (e.g. a server item), can't be put on v2. Replace each one:

  • if the survey needs the value (a showif, a default, a random group), with a hidden item with the same value (see below).
  • if feedback or a later module needs it (a score, a condition for Skip Forward, a payment code), by computing it there, from the stored answers.
Bridging R into a showif

To show items based on something only R can compute, put the R into a hidden item's value and use that item's name in the showif, as older does in the example. Its value is stored with the results.

  • It is computed when its page is shown, from the answers so far (its own page's are usually still empty).
  • If its R uses another item of this survey, it is computed again when its page is shown after that answer changed. Anything else (sticky, another survey's data, a sample()) is computed once, so a random group isn't drawn again.
  • A logical result arrives as the text TRUE or FALSE, so return numbers, as ifelse() does above.
  • The value goes to the server with the page, from the participant's browser, so a participant (or a bot) could change it. Compute what you analyse again in a later module.
  • If the page's R can't be loaded (no connection, too many requests), the item is submitted empty.
  • A page of only hidden items is never shown. Its values are stored with the last page shown before it, or with the first page for hidden items at the start. So hidden items after your last submit see every answer.

Nothing in a v2 form is secret. Every answer it stores can be read in the participant's browser, because showifs may use it. Keep a value participants must not see (their condition, say) in another survey, and out of showifs.

Reserved item names

No item can be called session_id, study_id, iteration, created, modified, ended or expired (in any capitalisation), id or session (the participant's user code). Only a classic survey still lets an item that stores no answer (a note, a submit) be called expired, session or another capitalisation of these. On v2, isNA, answered, contains, containsWord, startsWith, endsWith, last and init are taken too. Rename such an item before you move a survey to v2.

Layouts

Layout changes only how pages are presented, so you can change it while your study is running.

Default

All items up to the next submit item are shown together, with Page 2 of 5 above them. On phones, the Next button stays at the bottom of the screen. Previous appears only with Allow "Previous" button on. A small indicator shows Saving…, Saved, Synced or Saved offline.

Solo

Each item gets a screen of its own. Pages are still submitted at your submit items, and items hidden by a showif are skipped. Keep labels short, and put a note before a block of questions rather than help text on every item.

  • Single-choice items (mc, mc_button, rating_button, select_one, sliders such as visual_analog_scale) move on once an answer is picked. Checkboxes, multiple selections and text need OK.
  • Enter moves on (in a text area, Ctrl+Enter or ⌘+Enter). ↓ and ↑ go to the next or previous item when the item doesn't need them.
  • Back goes to the previous item on the page. Earlier pages need Allow "Previous" button.
  • The progress bar never moves backwards, even when a showif adds items.

Autosave and offline

Autosave sends changed answers in the background, at most every 20 seconds, and right away when the participant switches to another app or closes the page. While a change waits, the browser asks before they leave. Answers that fail their item's checks aren't autosaved, and bot_check, turnstile and file uploads go only with the page. Participants who come back find their answers.

Next and Submit check the page in the browser, then on the server, which marks problems as in a classic survey. The next page appears right away, because it is already in the browser. If a required item on an earlier page is still empty when the last page is submitted, the participant is taken back to it.

The offline queue

With Enable offline queue on, a page that can't be sent (no connection, a problem on the server) is kept on the device, and the participant goes on, with Saved offline and a banner on screen. On the last page, they wait until it has gone. A page the server turns down (an answer that fails its check, an expired link) is not kept.

Queued pages are sent in order once the connection is back, from an open page of the survey (a closed tab sends nothing). A page that arrives twice is stored once. On a page shown while offline, R labels and values (hidden items too) stay empty until the connection is back, and a page submitted before that goes without them.

A queued page is checked when it arrives. If it fails (a required answer is missing, say), a banner asks the participant to fix that page and takes them there, and later pages wait behind it. A page that keeps failing for other reasons stays on the device, with Retry now and Discard and continue (which deletes its answers) on the banner. Pages for a survey that has ended meanwhile can't be stored any more.

  • Files are queued too, up to 10 MB each (instance setting form_v2_offline_blob_max_mb).
  • Queued answers sit as plain text on the device until they are sent. A participant who logs out (Delete Session Now / Logout) with unsent pages is asked whether to keep or delete them.
  • The queue belongs to the browser. Unsent pages stay on the device they were answered on.

New item types

  • rank for putting the choices in order, by dragging, with buttons or with the keyboard. v2 only.
  • bot_check has the browser solve a small puzzle to show that a person is filling in the page. No third party is involved. v2 only.
  • visual_analog_scale, a slider without a visible starting point. It works on v1 too.
  • turnstile stores Cloudflare Turnstile's verdict on whether the participant is a bot. It sends data to Cloudflare, so it's only there if your server's administrator has set it up, and it needs your participants' consent (see the data protection notes). v2 only.

Don't give a bot_check or turnstile a showif: a bot can claim that the showif hid it. All four are described under Item types.

Data and results

Answers are stored as in a classic survey, so results, exports and R elsewhere in your study (diary$mood_why) work as before. The differences:

  • You get the answers a participant gave before they broke off mid-page.
  • Emptying a field or unticking a choice removes the stored answer.
  • An item a showif hides is empty, even if its answer was autosaved while it was shown.
  • get, ip, browser, server, referrer and random items are stored when participants first open the form, whichever page they're on, not when their page comes up. So a get item on page 3 stores the parameter of the address the form was opened with.
  • A form of nothing but such items ends by itself, also when formr reaches it while the participant is away. One with hidden items, or one that showifs leave empty, waits for the participant's visit, so compute what later modules need in their own R.
  • mc_heading rows aren't shown. Each item below shows its own choice labels, also with the class hide_label. Put a heading that participants need to read in a note.
  • A choice value 0 is stored. Ticking 0 and 2 in an mc_multiple, mc_multiple_button or select_multiple stores 0, 2 on v2 and 2 on v1.
  • select_or_add_multiple separates answers with semicolons (Berlin, Germany;Paris), so its choices can't contain one. A choice list for select_or_add_one or select_or_add_multiple written in one cell is split at semicolons on v2 (red;green;blue) and at commas on v1.
  • The item display table (Export Run Data, Detailed Results) records when each item came into view and how often, rather than when its page loaded (see The study's export).

Compatibility check

Check v2 compatibility (in the box Survey engine: v1 or v2, or under v2 settings) lists what to change in a survey, and how, without changing anything. It flags:

  • showifs with R in them (Need a JavaScript rewrite): R functions such as ifelse() or current(), is.na(), %…% operators, TRUE, FALSE, NA, <-, stringr:: or survey$item. Text in quotes doesn't count. A single & or | is flagged where one side isn't a comparison, as in smoker & drinks.

  • showifs that use a name that isn't an item of this survey (Use something not in this survey), such as ran_group.

  • items v2 can't run: calculate and the like, an item named like a showif helper, a select_or_add_multiple choice with a semicolon. These block the move.

  • choice lists written in one cell with commas, which would be a single choice on v2.

It also names three things that don't stop the move: showifs with <, <= or != that are true while their item is unanswered and don't check it with answered() or isNA(), mc_heading rows (v2 leaves them out), and studies that use the survey and whose own JavaScript uses jQuery, which v2 pages don't have.

Values are never flagged. Fix showifs with the table above or a hidden item. The check is a heuristic, but a showif the browser can't run hides its item from every participant, which is why flags stop Move to v2 unless you choose Move to v2 anyway.

Server administrators can run the same check as php bin/form_v2_compat_scan.php <survey id or name>, which exits with 2 if anything is flagged or a study's JavaScript uses jQuery.

Upgrade checklist

For a survey that is already collecting data:

  1. Run the compatibility check.
  2. Download the items (Download Items), fix what the check flagged in that file, give it a new name (diary2.xlsx, not diary-v2.xlsx, which formr reads as diary), and upload it with Engine set to v2. Run the check again on the copy.
  3. Walk through every page of the copy with Test Survey, looking at the flagged items and the R values in particular.
  4. Use the copy in your study instead of the original: on Edit Run, pick it in the Survey module's list and save. Do it between two waves, or when nobody is at the survey (the blue number next to the module). Someone in the middle of the old survey would not carry on where they stopped. New answers are stored under the copy's name, so you'll combine both surveys' results.
  5. Change every piece of R in your study that names the old survey: Skip conditions, Pauses, feedback texts, email recipients, other surveys' values and labels. They still read the old survey's answers, so a loop on nrow(diary) < 14 has to count both, nrow(diary) + nrow(diary2) < 14, and an Email to diary$email finds no new address.
  6. If your study has JavaScript of its own (its JS tab), rewrite what uses jQuery ($). On a v2 form it runs once, when all pages are in the browser (see JS).
  7. Set the copy's v2 settings.

A survey that no study uses yet needs only steps 1 and 3: Move to v2 keeps its name and its results. After an update to formr 2 lists what the update itself changes for a study that is running.

Instance settings

The administrator of a formr server can change these. Details are in documentation/form_v2_upgrade.md in the formr repository.

SettingDefaultWhat it does
form_v2_enabledfalseoffers v2 for new surveys and Move to v2. Surveys already on v2 keep working without it.
form_v2_rate_limits30, 90, 10, 20 per minuteper participant: requests for a page's R, saves (page submits, autosaves, queued pages), the installed app's logging requests (per IP address), and bot_check puzzles
form_v2_rcall_ttl300 show long an R result is reused for the same answers
form_v2_offline_blob_max_mb10the largest file (in MB) a page can take into the offline queue
bot_check_*see form_v2_upgrade.mddifficulty, memory, time, lifetime and secret of the bot_check puzzle

Knit R & Markdown


This section gives some guidance on how to format and customise text in formr. In many cases you'll do it right by default. You'll also see how to access the data you just collected in formr in R — for example to score an assessment, give feedback, or customise the study in other ways.

Markdown

You can format text/feedback everywhere (i.e. item labels, choice labels, the feedback shown in pauses, stops, in emails) in a natural fashion using Github-flavoured Markdown.
The philosophy is that you write like you would in a plain-text email and Markdown turns it nice.
In most cases, characters with special meaning won't entail unintended side effects if you use them normally, but if you ever need to specify that they shouldn't have side effects, escape it with a backslash: \*10\* doesn't turn italic.

* list item 1
* list item 2

will turn into a nice bulleted list.

  • list item 1
  • list item 2

# at the beginning of a line turns it into a large headline, ## up to ###### turn it into smaller ones.

*italics* and __bold__ are also easy to do.

[Named links](https://yihui.org/knitr/) and embedded images ![image description](https://imgur.com/imagelink) are easy. If you simply paste a link, it will be clickable automatically too, even easier. Email addresses are a bit special, you need the "mailto:" prefix: [Contact us](mailto:contact_email@example.com).

You can quote something by placing a > at the beginning of the line.

If you're already familiar with HTML you can also use that instead, though it is a little less readable for humans. Or mix it with Markdown! You may for example use it to go beyond Markdown's features and e.g. add icons to your text using <i class="fa fa-smile-o"></i> to get for instance. Check the full set of available icons at Font Awesome.

Knitr

If you want to customise the text or generate custom feedback, including plots, you can use Knitr. Thanks to Knitr you can freely mix Markdown and chunks of R. You can load data using R commands, but the data you just collected for this participant will automatically be made available as R data frames. See R helpers for more information. Some examples:

  • Today is `r date()` shows today's date.
  • Hello `r demographics$name` greets someone using the variable "name" from the survey "demographics".
  • Dear `r ifelse(demographics$sex == 1, 'Sir', 'Madam')` greets someone differently based on the variable "sex" from the survey "demographics".
  • You can also plot someone's extraversion on the standard normal distribution.
    ```{r}
    library(formr)
    # build scales automatically
    big5 = formr_aggregate(results = big5, item_list = NULL)
    # standardise
    big5$extraversion = scale(big5$extraversion, center = 3.2, scale = 2.1)
    
    # plot
    qplot_on_normal(big5$extraversion, xlab = "Extraversion")
    ```
            
    yields
    Graph of extraversion bell curve feedback

R Helpers


R in formr

In formr, you can use R to write simple and complex code. R code goes into the value column, the showif column of a classic survey, the conditions of Skip Forward and Skip Backward, the relative to of a Pause or Waiting Time, and External Link addresses. R mixed with Markdown goes into labels, Stop Point and Pause texts, and emails. The R code you wrote will be automatically enriched with the data objects you name and processed using OpenCPU. By default, your participants cannot view the R code you write.

Automatically enriched data

When you write R code in formr, we try to automatically determine what data you need and supply it. To do so, formr has a look up table of all the available data (the surveys defined in the study, the items defined in these surveys, as well as some metadata about the participant and their progress through the study).

For example, to obtain somebody's age, you need only write demographics$age. formr will then automatically create a data frame named "demographics" containing the variable "age". To give another example, to see whether a participant ever reported a headache in your diary, you might just write any(diary$headache > 1). In this case, formr would create a data frame containing all responses to the headache question. It's important to note that formr simply checks whether the name of the survey exists anywhere in the text and whether the name of the item exists anywhere else. So, demographics$age works, but so does demographics[, 'age']. If an item name exists in multiple surveys that you have named, it will be supplied for all surveys.

Available data
user_id
The unique user code which we use for logging people in, e.g. NqbpASFVlcci5cnVvpMZG4ueILaYvFk39fDND305XvPLh3KW4xzrP0ygJ1phs1gf.
.formr
$login_link $login_code $nr_of_participants $session_last_active $run_name
Useful shortcuts to obtain the link to the personalised study link, the login code (currently the same as user_id), the total number of participants in the study (every user code: also those who only saw the first page, your test users and people you added beforehand), as well as a date-time when the current participant was last active. For a link that other people get, use only the code's last ten characters: stringr::str_sub(.formr$login_code, -10). .formr$run_name is your study's name. formr sets it when your code calls formr_api_authenticate(), and formr_api_results() and formr_api_fetch_results() use it as their default, so inside your study you can leave the name out.
YourSurvey
$YourItem1
$YourItem2
Any of the surveys that are part of the study and any of their items can be requested in this way. In addition, if you have named items belonging to a scale with a numeric suffix and an optional R, you need only name the scale (e.g. extraversion) and all items (e.g. extraversion1, extraversion2R, extraversion3) will be supplied.
survey_users
$created
$modified
$user_code
$email
$email_verified
$mobile_number
$mobile_verified
This data frame contains user account information, such as when the account was created, the user's contact details, and whether they have been verified. This is usually empty, because most study participants don't sign up on formr.
survey_run_sessions
$session
$created
$last_access
$ended
$position
$deactivated
$no_email
This data frame tracks user sessions in the study, including when they started the study (created), last accessed it, ended it (reached a Stop Point), the current position in the study, and whether the user has opted out of email notifications.
survey_unit_sessions
$created
$ended
$expired
$unit_id
$position
$type
$result
$result_log
This data frame contains metadata about the progression of the user through the study, including when they reached each module (created), left it (ended), and so on. result says how each module went (e.g. email_sent, survey_completed, external_compute), and result_log holds the value that an External link's R code returned, e.g. tail(na.omit(survey_unit_sessions$result_log[survey_unit_sessions$result == "external_compute"]), 1). You can keep interim results that way. For other modules, result_log has details meant for you (e.g. a mail server's error), so don't show it to participants. formr supplies these two only where your code reads them off the data frame, as here. na.omit(survey_unit_sessions) alone doesn't get them.
externals
$created
$ended
$position
Metadata about the study's External links, i.e. when users were sent there, whether they returned/completed the External link (ended) and the position in the study.
survey_items_display
$created
$saved
$answered
$displaycount
$item_id
This data frame has a row for each item of each survey the participant was given: when the answer was last changed (answered), when it reached formr (saved) and how often the item was shown (displaycount). Classic surveys and v2 forms count a little differently (see The study's export is a different table).
survey_email_log
$email_id
$created
$recipient
This data frame logs email interactions, including when an email was sent and its recipient.
shuffle
$unit_id
$created
$group
This data frame tracks the Shuffle modules a participant passed and the group each gave them.

Packages

Wherever you use R in formr you can also use the functions in its R package. If you want to use the package in a different environment, you'll need to install it using the following code.

install.packages('formr')

The package's website documents every function.

The package currently has the following feature sets

  • Some shorthand functions for frequently needed operations on the site:
    first(diary$mood) # first non-missing value
    last(diary$mood) # last non-missing value
    current(diary$mood) # last value, even if missing
    "formr." %contains% "mr." # will yield TRUE
    "formr." %contains_word% "mr" # will yield FALSE
    "12, 15" %contains% "1" # will yield TRUE
    "12, 15" %contains_word% "1" # will yield FALSE
    stringr::str_sub(.formr$login_code, -10) # the last 10 characters of the user code, for links that others get
    # login_code(10) does the same from version 1.4.0 of the formr package on
  • Some helper functions to make it easier to correctly deal with dates and times:
    time_passed(hours = 7) 
    next_day()
    in_time_window(time1, time2)
  • Getting your data through formr's API (the formr_api_*() functions), correctly typing all variables, automatically aggregating scales. Version 1.3.0 of the package has limits with v2 forms, named users and surveys filled out several times (see Straight into R).
  • Easily making feedback plots e.g.
    qplot_on_normal(0.8, xlab = "Extraversion")

    The package also has a function to simulate possible data, so you can try to make feedback plots ahead of collecting data.

R Functions

If you need the same R code in many places, define it once on the R Functions tab of your study's settings. formr runs that code before every piece of R in the study (showif and value, conditions, feedback, email texts and so on), so you can call your functions by name everywhere. For example, with

mean_score <- function(x) {
  mean(x, na.rm = TRUE)
}

on the R Functions tab, a value can be mean_score(diary$headache). Save & Test R Syntax checks that the code parses, but doesn't run it. The code is part of your study's export.

There are a few catches:

  • formr supplies only the data your code names (see above), and it doesn't look inside R Functions. So pass the data to your function as an argument, as in mean_score(diary$headache), instead of reading diary inside the function.
  • formr lets code use the API if the code or one of your R Functions calls formr_api_authenticate(). In R Functions, make the call inside a function, not at the top level. That part runs before access is set up, so the call fails there.
  • Because the code runs so often, anything slow there (e.g. loading many packages) slows down every page.

Further data

Sometimes, you need more than the data that formr auto-enriches your study with. For example, you might have designed a couples' diary study and need the partner's data to synchronise participation. In these cases, you will have to explicitly load the data using formr's API. Inside your study, you need no credentials for this, as long as the study's owner has API access (admin level 2, see the API tab). Call formr_api_authenticate() without arguments, then use the formr_api_*() functions:

formr_api_authenticate()
all_diaries <- formr_api_results(surveys = "diary")

Without API access, formr_api_authenticate() stops with "No credentials found".

Other times, you might want to import data from elsewhere on the web. You can use R packages and functions to, for example, read a participant's social media posts or to look up information in an external, online database. If that service needs a key, keep it in an R Secret.

R Secrets

Some R code needs a value that nobody should see, such as the key of an external service. Store it on the R Secrets tab of your study's settings. A secret named api_key is then available in your R code as .formr$secret_api_key:

weather <- httr::GET("https://api.example.org/weather",
  query = list(city = demographics$city, key = .formr$secret_api_key))
  • Names can contain letters, digits and the underscore.
  • Secrets are write-only. formr stores them encrypted and never shows a value again once you've saved it. You can only replace or delete it.
  • formr sends a secret to R only if your code (or your R Functions) contains its reference written out, .formr$secret_api_key. A reference you build while the code runs, e.g. .formr[[paste0("secret_", name)]], finds nothing.
  • formr hides secret values of at least 6 characters in error messages, debug output and logs. It doesn't hide them in pages or emails your code writes, so never print a secret. Use long, random values.
  • When you export your study, the export lists the names of its secrets, not their values. Importing it creates the secrets with empty values, for you to fill in.

R Secrets don't give anyone access to your study's data. If someone needs to read it from outside formr, create an API credential for them (see the API tab).

Features


The following designs and many more are possible:

  • simple surveys with and without feedback
  • complex surveys (using skipping logic, personalised text, complex feedback)
  • surveys with eligibility limitations
  • diary studies with automated reminders
  • longitudinal studies (e.g. automatically re-contact participants after they return from their exchange year). The items of later waves need not exist in final form at wave 1.
  • longitudinal social networks and other studies that require rating a variable number of things or persons

Core strengths

  • feedback with plots, made live from each participant's answers: ggplot2, and interactive ones with plotly and other htmlwidgets.
  • reminders by email, push notification or text message, for diaries, experience sampling and training studies.
  • pages that work on phones, and studies that participants can add to their home screen like an app.
  • surveys as spreadsheets you can share and reuse, and whole studies you can export and import.
  • R wherever a study needs logic (conditions, scores, feedback, calls to other services), with the packages this instance has.
  • links to other tools (reaction time tasks, other survey software) and back.
  • ratings of participants by their peers (see Peer ratings).

More features

  • manage access to and eligibility for studies
  • text messages through a provider of your choice (see the HowTo)
  • formats text using Github-flavoured Markdown
  • file, image, video, sound uploads for users (as survey items) and admins (to supply study materials)
  • complex conditional items
  • keeps working when the connection drops: in a v2 form, a page a participant submits while offline is stored on their device and sent once they're back online (see Autosave and offline)
  • a dedicated formr R package with helpers for feedback plots and study logic, and for importing, scoring and simulating survey data
  • a nice editor, Ace, for editing Markdown & R in studies.

formr API


With formr's API, your own code can read your studies' data, upload surveys, and create and change studies. This formr instance's API is at https://api.researchmixtape.com, and every address on this page is relative to it: POST /oauth/access_token means https://api.researchmixtape.com/oauth/access_token, and GET /v1/runs means https://api.researchmixtape.com/v1/runs.

If you work in R, the formr R package does most of this for you with its formr_api_*() functions (see Using the API in R below). The rest of the page is for other languages, and for looking up what each call does.

API credentials and R Secrets are different things. If someone needs to read a study's data from outside formr, don't give them your login. Create an API credential for them on your account page (Account → API Credentials, see step 1 below). A value you add under your study's Settings → R Secrets (e.g. another service's key) is for your own R code in the study, which reads a secret named api_key as .formr$secret_api_key. It gives nobody access to the API.

Connect an AI assistant (MCP)

This formr instance has an MCP server: https://formr.researchmixtape.com/mcp. Add it to Claude, Claude Code, ChatGPT, Codex or VS Code. The app sends you to formr to sign in, and there you choose what it may do, as for a credential (it needs admin level 2, too). Each app you connect is listed under Account → API Credentials, where you can change or delete it. How to connect each app, and what an assistant can do: AI assistants.

1. Get API credentials

R code inside your own study (e.g. a showif or a page) needs no credential, but the study's owner needs API access as below (see Using the API in R).

The API needs admin level 2 on your account. The rights to create studies (see Getting Started) give level 1. If the API Credentials tab on your account page says you have no API access, ask the people who run this formr instance for it.

Then open Account → API Credentials and fill in "Create a new credential":

  1. A label, to tell your credentials apart (e.g. dashboard, cron-2026). It must be unique in your account, and internal is taken.
  2. The scopes, i.e. what the credential may do (see the table below). A credential needs at least one.
  3. The runs it may use. Select none, and it may use all your studies, also those you create later. Select some, and it may use only those, and only the surveys that are part of them. Such a credential can't create studies or surveys.
  4. Click Create credential. formr asks for your password, unless you logged in within the last 15 minutes.

The page then shows the client_id, the client_secret and the R command that stores both. Copy the secret right away. formr keeps only a hash of it and can't show it again.

ScopeLets the credential
user:read, user:writeread your profile, change it
run:readlist your studies, read their settings and units
run:writecreate studies, change their settings and units
run:deletedelete studies. Until v2.0.0-rc13, run:write allowed this, so credentials that had run:write then have both.
survey:read, survey:writeread surveys, upload, change and delete them
session:read, session:writesee your participants and where they are, add participants and move them on
data:readread your participants' answers
file:read, file:writelist a study's files, upload and delete them

You can hold several credentials side by side, e.g. a narrow read-only one for a dashboard and a broader one for a script. The API Credentials tab lists them. Rotate gives one a new client_secret (the client_id stays), and lets you change its scopes and runs. Tokens it gave out before keep their old scopes until they expire. Delete revokes it at once: whatever still uses it gets a 401 from its next call.

Giving a collaborator the data of one study

Say a colleague should download one study's answers, but not see your other studies, change anything, or get your login. Make a credential for exactly that:

  1. Label it for the person, e.g. colleague-download.
  2. Tick data:read. If they use formr_api_results() in R, tick run:read too (it reads the study's units), and session:read if it should leave out your test users. Without a :write scope, the credential can't change anything.
  3. Select only that study under runs. The credential is refused for every other study, and for every survey that isn't part of this one.
  4. Send your colleague the client_id, the client_secret and the API's address (https://api.researchmixtape.com). They need no formr account.

They get the answers with GET /v1/runs/{name}/results, or formr_api_results() in R. When the project ends, delete the credential.

2. Get an access token

Exchange the credential for an access token. A token works for 1 hour.

POST /oauth/access_token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id={client-id}&client_secret={client-secret}

(You can also send the client_id and client_secret by HTTP Basic authentication.) The answer:

{
    "access_token": "XXXXXX3635f0dc13d563504b4d",
    "expires_in": 3600,
    "token_type": "Bearer",
    "scope": "run:read data:read"
}

scope lists the credential's scopes. If it says formr:none, the credential has no scopes and every call is refused: rotate it and tick at least one scope. A wrong client_id or client_secret gets a 400:

{
    "error": "invalid_client",
    "error_description": "The client credentials are invalid"
}

3. Call the API

Send the token in a header with every request:

Authorization: Bearer {access-token}

formr refuses a token in the address or the request body (401). These are the calls, {name} being a study's or survey's name and {code} a participant's user code:

CallScopeWhat it does
GET /v1/user/meuser:readyour profile
PATCH /v1/user/meuser:writechanges it
GET /v1/user/tokennonewhat the token is: its account, scopes, expiry and runs
GET /v1/runsrun:readlists your studies
POST /v1/runs/{name}run:writecreates a study
GET /v1/runs/{name}run:reada study's settings
PATCH /v1/runs/{name}run:writechanges them
DELETE /v1/runs/{name}run:deletedeletes the study
GET /v1/runs/{name}/structurerun:readits units
PUT /v1/runs/{name}/structurerun:writechanges its units
GET /v1/runs/{name}/sessionssession:readits participants and where they are
POST /v1/runs/{name}/sessionssession:writeadds participants
GET /v1/runs/{name}/sessions/{code}session:readone participant
POST /v1/runs/{name}/sessions/{code}/actionssession:writemoves a participant on, and more
GET /v1/runs/{name}/unit_sessionssession:readevery unit each participant reached
GET /v1/runs/{name}/resultsdata:readthe answers to its surveys
GET /v1/runs/{name}/filesfile:readits files
POST /v1/runs/{name}/filesfile:writeuploads a file
DELETE /v1/runs/{name}/files/{file}file:writedeletes a file
GET /v1/surveyssurvey:readlists your surveys
POST /v1/surveyssurvey:writeuploads a survey, new or changed
GET /v1/surveys/{name}survey:readits items
PATCH /v1/surveys/{name}survey:writechanges its settings
DELETE /v1/surveys/{name}survey:writedeletes it

A credential restricted to some runs lists only those, and only the surveys that are part of them.

Your account

GET /v1/user/me gives your id, email, first_name, last_name, affiliation, email_verified and created, your admin level, the token's scopes, and allowed_runs: the runs the credential is restricted to (null if it may use all). PATCH /v1/user/me takes first_name, last_name and affiliation.

GET /v1/user/token works with any token. It gives the account_id, client_id, label, scopes, expires (Unix time) and allowed_runs, and the email only with user:read.

Studies

GET /v1/runs takes ?name= (part of the name) and ?public= (0 to 3). POST /v1/runs/{name} creates a study with that name, which must start with a letter and have 3 to 45 letters, digits and hyphens. It answers with its name and link.

GET /v1/runs/{name} gives the study's settings and its link. PATCH /v1/runs/{name} takes a JSON object with any of title, description, footer_text, public_blurb, privacy, tos, header_image_path, custom_css, custom_js, custom_r, cron_active, use_material_design, expiresOn, expire_cookie_value, expire_cookie_unit, public and locked, and ignores other fields. public is the run's Publicness, from 0 (only you and test users) to 3 (everyone, listed on the studies page). As in the admin area, a study can be opened to participants only once it has a date when its data will be deleted (expiresOn), unless this instance keeps data without limit, and a privacy policy if the instance requires one. A change formr refuses gets a 400 that says why. If it refuses expiresOn (the date has to be after today, written as YYYY-MM-DD), it saves nothing of what you sent. If it refuses public, the other settings are saved all the same. A date further ahead than this instance allows is cut to the latest allowed, and so is a cookie lifetime longer than it keeps a session, each with a warnings text in a 200 answer. null or an empty text removes the date.

DELETE /v1/runs/{name} deletes the study with its participants and their results. formr saves these in result backups first, and deletes nothing (500) if it can't. If participants keep starting the study meanwhile, formr answers 500 too, with those from before already deleted and their results backed up. Make the study private first to avoid this.

Participants

GET /v1/runs/{name}/sessions lists the participants, newest first, 100 at a time (?limit= up to 10000, ?offset=). ?active=true lists those who haven't reached the end yet, false those who have. ?testing=true lists only test users, false only real participants. Each has their user code (session), position, created, last_access, ended, testing, and the unit they're at (current_unit). GET /v1/runs/{name}/sessions/{code} gives the same for one participant.

POST /v1/runs/{name}/sessions adds participants. Send {"code": "…"}, or a list of codes, and "testing": true to make them test users. Without code, formr makes one participant with a random code. A code you choose may use only letters, digits, -, _ and ~, and it must fit this instance's format for user codes (by default exactly 64 such characters). The answer lists the new codes in sessions (201), and the ones it couldn't add in errors (207), each with its code and the reason. If it could add none, you get a 400, with the same list in errors. Participants take part through the study's link with ?code= and their code.

Moving participants on

POST /v1/runs/{name}/sessions/{code}/actions with a JSON body such as {"action": "advance"} does one of these to a participant (scope session:write):

actionWhat it does
advanceends the unit they're at and starts the next one. formr records the unit as moved on, not as finished. Refused (400) if they have reached the end, are at no unit, or formr is busy with them right now (try again).
move_to_positionsends them to the unit at position, which must have one (e.g. {"action": "move_to_position", "position": 30}), also if they had reached the end. The unit they were at ends. formr runs the new one at their next visit, or when you send execute. (Users in the admin does both steps at once.) If no unit is at that position, you get a 400 and nothing changes.
executeruns the unit they're at as formr does by itself while they're away, and goes on through units that need nothing from them (e.g. an Email, a Skip Forward, a Pause that is over).
end_externalends the External link they're at when it is set to "end using API" (see below). formr then runs the next unit by itself, usually within 20 seconds. If they're at no such link, nothing happens. The call names the participant, not the External link, so one that comes twice, when they have reached the next such link, ends that one.
toggle_testingmakes them a test user with "testing": true, a real participant with "testing": false or without testing (version 1.3.0 of the R package can't send testing, so from R it only makes test users real).

advance and execute run units as formr's cron job does, because the participant isn't there. A Waiting Time waits for them, an External link sends them off at their next visit, and an Email set to Send e-mails only when cron is running is sent. A survey waits for their visit. A Stop Point is the exception: it ends their session at once.

An action that worked answers 200 with an empty JSON array ([]), one that didn't an error with a message. In R, formr_api_session_action() sends these.

Unit history

GET /v1/runs/{name}/unit_sessions lists every unit each participant reached, one row each time, where /v1/runs/{name}/sessions gives only where they are now. The rows come by participant and then in order of time, so consecutive rows of one participant are their path through the study. The default Overview script draws its Sankey diagram from them.

?session= takes one user code or several, comma-separated, ?testing=true or false works as above, and ?since= (a date and time, ISO 8601) gives only the rows created since then, e.g. for a dashboard. You get 1000 rows at a time (?limit= up to 10000, ?offset=). Each row has the participant's session and testing, the unit (unit_type, unit_description, position, iteration), created, expires, ended, expired, result and state (PENDING, RUNNING, WAITING_USER, WAITING_TIMER, ENDED, EXPIRED or SUPERSEDED, empty on old rows). The study's special units (the Overview script, the service message, the reminder email) have no position.

Results

GET /v1/runs/{name}/results gives the answers to all the study's surveys in one object, with a key per survey. Each holds a row for each time a participant was given that survey, with their user code (session), created, current_position and a field per item. To get less, give comma-separated lists: ?surveys= names surveys, ?items= names items (of every survey you get), and ?sessions= names participants by user code (a code also matches the codes that start with it). Test users' rows are included, and not marked: ?testing=true on /v1/runs/{name}/sessions tells you who they are.

Times and dates with a time come as the browser sent them (14:30, 2024-05-01T14:30). R inside your study, Show Results and Export Results have them as 14:30:00 and 2024-05-01 14:30:00.

The key shuffles holds a row for each time a participant passed a Shuffle: their user code (run_session), the Shuffle's position, the group they got (group_1, group_2, …) and created.

A survey that hides its results gives no rows. An unlinked survey gives its rows without user code, time and position, in random order, and only test users' rows until more than 10 real participants have answered. Asked for by ?sessions=, it gives none. A study nobody has started yet gets a 404.

Files

GET /v1/runs/{name}/files lists the files of the study (Upload Files in the run's menu), each with its name, url, created and modified. POST /v1/runs/{name}/files uploads one, sent as multipart form data in the field file. In its name, anything but letters, digits, ., _ and - becomes _. DELETE /v1/runs/{name}/files/{file} deletes the file of that name.

Surveys

GET /v1/surveys lists your surveys (?name=, part of the name). POST /v1/surveys uploads one, as multipart form data: a spreadsheet in the field file (.xlsx, .xls, .ods, .csv, .txt or .xml), or the link to a Google Sheet in the field google_sheet. The survey's name comes from the file's name (big5.xlsx and big5-v2.xlsx are both the survey big5) or the sheet's. If you have a survey of that name, it is changed (200), else created (201). The answer has its id, name and formr's notes on the upload (logs).

GET /v1/surveys/{name} gives its items as JSON, or the item table as a file with ?format=xlsx or ?format=xls. PATCH /v1/surveys/{name} takes google_sheet (to import the survey again from that sheet) and the settings maximum_number_displayed, displayed_percentage_maximum, add_percentage_points, expire_after, expire_invitation_after, expire_invitation_grace, enable_instant_validation, unlinked, hide_results and use_paging. Once on, unlinked, hide_results and use_paging can't be turned off again.

A credential restricted to some runs can change or delete a survey only if no study outside those runs uses it.

DELETE /v1/surveys/{name} deletes the survey and its results in every study that uses it. formr saves these in result backups first, and deletes nothing (500) if it can't. If participants keep starting the survey meanwhile, formr answers 500 too, with the results from before already backed up and deleted.

Uploads that would delete answers

An upload that removes, renames or re-types items that real participants have answered takes their answers out of the survey's results. formr refuses it with a 409 and saves nothing, from POST /v1/surveys, from PATCH /v1/surveys/{name} with a google_sheet, and from PUT /v1/runs/{name}/structure. Before it saves any survey of a structure, formr checks them all, so the 409 names every one that would lose answers. Its message says so in words, and results_to_delete has an entry for each such survey:

  • survey is its name, and items lists the items that would lose answers.
  • real_participants is how many real participants (not test users) answered one or more of them.

items_with_results is the items of all these surveys in one list. An item that only test users answered, or nobody, isn't listed and doesn't need a confirmation.

A survey that hides its results, and an unlinked survey until it has more than ten results from real participants, don't say which items were answered: items lists all the items that would go, and real_participants is null. For any unlinked survey, it's also null unless more than ten participants are affected.

To go ahead, send the upload again with confirm_deletion: as ?confirm_deletion=1 or a form field with POST, as "confirm_deletion": true in the JSON with PATCH, and either way with PUT. It counts for every survey of the upload. formr then saves each survey's results in a backup before it changes the survey, and the answers also stay in its Detailed Results. The formr R package can't send it yet. If your program acts for somebody else, send it only once they've agreed to lose the answers of every survey and item the 409 listed.

If participants answer such an item while a structure upload is being saved, the surveys that were saved before are in surveys_saved. The study's units haven't changed then.

Changing a study's units

GET /v1/runs/{name}/structure gives the study's units, each with its run_unit_id, and a version. Send it back changed with PUT, and formr changes only what differs, as the run editor does:

  • A unit sent with its run_unit_id stays that unit. What you send is saved over it, and what you leave out stays as it is. Participants at it stay there, and move with it if its position changed.
  • A unit without a run_unit_id is new. That includes a copied unit: leave its run_unit_id out.
  • A unit sent with its run_unit_id but changed to another type, or to another survey, becomes a new unit.
  • A unit you leave out is removed. Participants at it go on to whatever now stands in its place, moved on by the study's cron job, or at their next visit if the cron is off.
  • A survey's survey_data changes the survey only where it differs from what the GET gave, and only with survey:write, as uploading the survey would (items that would go with real participants' answers need confirm_deletion). Of the settings, too, only those that differ are saved.
  • Send back the version you got. If the study's units or settings changed since (on Edit Run, by another upload, or in its settings), the PUT gets a 409, because it would undo those changes: fetch it again. A file added or deleted meanwhile doesn't count. Without version, the PUT overwrites.

If real participants (not test users) are at a unit you would remove, the PUT gets a 409 and changes no unit. Its units_in_use names those units and how many participants are at each. surveys_saved names the surveys whose changed items were saved all the same (a survey's items are saved first). To go ahead, send it again with ?confirm_removal=1, or "confirm_removal": true in the JSON. A PUT that worked says what changed: kept, moved, created, removed, participants_moved and steps_ended.

Answers and errors

A call that worked answers with what you asked for, as JSON: a list (GET /v1/runs, GET /v1/surveys) as an array, a single thing as an object. A call that didn't gets an HTTP status from 400 up and a message saying why. These are the ones you'll see when a credential doesn't fit the call:

// The token lacks the scope this call needs.
HTTP/1.1 403 Forbidden
{"code": 403, "message": "Insufficient permissions: 'run:write' scope required."}

// The credential is restricted to other runs.
HTTP/1.1 403 Forbidden
{"message": "This API client is not authorized for run 'foo'."}

// The credential is restricted to runs that don't use this survey.
HTTP/1.1 403 Forbidden
{"message": "This API client is not authorized for survey 'bar'."}

// A credential restricted to some runs can't create surveys.
HTTP/1.1 403 Forbidden
{"message": "Cannot create surveys with a run-restricted API client; add the survey to a run via the admin UI first, then update it via the API."}

formr checks the scope first, so a token without run:write gets a 403 on PATCH /v1/runs/foo whether foo exists or not. To fix a credential, click Rotate on its row under API Credentials and change its scopes or runs. Or create a new one, and delete the old one once nothing uses it.

4. Example with curl

# 1) Get a token
ACCESS_TOKEN=$(curl -s -X POST https://api.researchmixtape.com/oauth/access_token \
  -d grant_type=client_credentials \
  -d client_id=$CLIENT_ID \
  -d client_secret=$CLIENT_SECRET | jq -r .access_token)

# 2) List the studies this credential may use
curl -s https://api.researchmixtape.com/v1/runs \
  -H "Authorization: Bearer $ACCESS_TOKEN" | jq

# 3) Read one study's settings
curl -s https://api.researchmixtape.com/v1/runs/my-diary \
  -H "Authorization: Bearer $ACCESS_TOKEN" | jq

# 4) Move a participant on to the next unit
curl -s -X POST https://api.researchmixtape.com/v1/runs/my-diary/sessions/$USER_CODE/actions \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"action": "advance"}'

5. Using the API in R

The formr R package gets and renews tokens for you, and turns the answers into data frames. How to install it, with a walk-through: Getting Started.

library(formr)

# Once: keep the credential in your computer's keyring
formr_store_keys(
    host = "https://api.researchmixtape.com",
    client_id = "YOUR_CLIENT_ID",
    client_secret = "YOUR_CLIENT_SECRET"
)

# In each R session (this picks up the stored keys)
formr_api_authenticate(host = "https://api.researchmixtape.com")
formr_api_session()$scope
#> [1] "run:read session:read data:read"

runs <- formr_api_runs()                        # your studies
settings <- formr_api_run_settings("my-diary")  # one study's settings
units <- formr_api_run_structure("my-diary")    # its units
diary <- formr_api_results("my-diary")          # its answers, joined (see below)

# Every unit each real participant reached, in order
path <- formr_api_unit_sessions("my-diary", testing = FALSE)

formr_api_results() leaves out your test users, types the answers and computes scales (extraversion from extraversion1, extraversion2R, …). Version 1.3.0 of the package has limits with v2 forms, named users and surveys that participants fill out several times (Straight into R lists them). formr_api_fetch_results() gives you every row as formr sends it.

Inside your study, you need no credential. If R code in your study calls formr_api_authenticate() without arguments, formr gives it a token for that call. This works in a showif, an item's value or label, a Skip Forward's or Skip Backward's condition, a Pause, a page or email body, an External link's address and the Overview script, but not in an email's subject or a push notification's title and text. formr looks for the call in that code and in your study's R Functions. In R Functions, make the call inside a function, because access isn't there yet when formr runs that code.

The token is that of the study's owner (whose account needs API access, see step 1), works only for this study, and expires after 180 seconds. Its scopes are user:read, session:read, session:write, run:read and data:read. So your code can read the study's data (e.g. the partner's answers in a couples' study), but can't change its units, settings or surveys. formr_store_keys() is only for using the API from outside formr (your computer, a dashboard, a cron job).

Ending an External link through the API

If you tick "end using API" in an External link, formr sends the participant to your address and keeps them at that unit until your service says they're done. Until then, each visit to the study sends them there again. Put {{login_code}} in the address so your service gets their user code. When they're done, your service makes one of these calls:

  1. POST /v1/runs/{name}/sessions/{code}/actions with {"action": "end_external"} and a token of a credential with session:write. Keep its secret on your server, never in a page the participant loads.
  2. POST /post/end-last-external with the JSON {"run": {"name": "my-study", "session": "<user code>"}} as the body. This needs no token: knowing the user code is enough, as it is for the participant's own link.

formr answers right away and then runs the next unit by itself, usually within 20 seconds, as it does while participants are away. A Pause starts waiting, an Email goes out and a Skip Forward is evaluated. A survey, a Stop Point or another External link waits for their visit. So participants don't have to come back to the study for it to go on. If your service sends them back to the study's link, they go on at once. If the study's Automated actions are off (General settings), the next unit waits for their visit.

Older addresses

These still work. New code should use the v1 calls above.

GET /get/results (scope data:read) gives the answers to a study's surveys, like /v1/runs/{name}/results but without shuffles:

GET /get/results?
     run[name]={name of the study}
    &run[sessions]={comma-separated user codes, empty for all}
    &surveys[survey_name_1]={comma-separated items, empty for all}
    &surveys[survey_name_2]={comma-separated items, empty for all}

Authorization: Bearer {access-token}

Without surveys[…], you get all the study's surveys.

POST /post/create-session (scope session:write) adds participants. Send {"run": {"name": "my-study", "code": ["code1", "code2"]}} as the body, or without code for one with a random code. It answers with created_sessions and the new codes in sessions.

POST /post/end-last-external (no token) ends an External link, see above.

AI assistants (MCP)


An AI assistant connected to formr can look at your studies, explain them, build and change their modules and surveys, and walk test users through them, in conversation. It connects through formr's MCP server (MCP, the Model Context Protocol, is how AI apps reach other services) and acts as you, with no more than you allow.

This instance's MCP server: https://formr.researchmixtape.com/mcp. You need admin level 2, as for an API credential (Account → API Credentials says how to ask for it).

Connecting

Add the MCP server's address to your app. The app then sends you to formr to sign in.

AppHow
Claude (web, desktop, mobile) Settings → Connectors → Add custom connector, and paste the address. On a Team or Enterprise plan, an owner may have to add it for the organisation first.
Claude Code claude mcp add --transport http formr https://formr.researchmixtape.com/mcp, then /mcp to sign in.
ChatGPT (web) Add a custom MCP server with the address, under Plugins or under Settings → Apps with developer mode on (where depends on your plan). Authentication: OAuth. If ChatGPT asks how to register, choose the client metadata document (CIMD). OpenAI decides which plans may add servers and use tools that change things.
Codex (CLI, IDE, app) codex mcp add formr --url https://formr.researchmixtape.com/mcp, then codex mcp login formr. In the Codex app: Settings → MCP servers → Add server, Streamable HTTP.
VS Code (GitHub Copilot) Command Palette → MCP: Add Server → HTTP, and paste the address. Or in .vscode/mcp.json: {"servers": {"formr": {"type": "http", "url": "https://formr.researchmixtape.com/mcp"}}}. Its tools are in Copilot Chat's agent mode. Your organisation's Copilot policy may have to allow MCP servers.
Cursor, Gemini CLI, others Not through formr's sign-in, see Other apps.

The apps' menus change often. If a step isn't where it says, look for "MCP server", "connector" or "custom app" in the app's settings.

Signing in

The app opens formr. You log in as usual (with your second factor, if you use one). If you were logged in already, and that was more than 15 minutes ago, formr asks for your password again. Then you choose what the app may do:

  • The scopes, i.e. the parts of the API it may use, as for a credential. To design and change studies: run:read, run:write, survey:read and survey:write. To make and walk test users, session:read and session:write, and data:read to see what they recorded. For the study's files, file:read and file:write. Tick run:delete only if it should be able to delete whole studies.
  • Which runs? None selected means all your studies, also those you create later. Select some to keep it to those.

Click Allow, and formr makes a connection. The app gets no password or secret of yours. formr gives it tokens of its own, each for an hour, and the app renews them while the connection lasts.

What it can do

  • List your studies, create new ones, change their settings, and delete them (with run:delete). Studies real participants have taken part in are kept, unless your administrators allow it.
  • Read a study's modules, add, remove, copy and move them, write surveys item by item as you would in a spreadsheet, and take a survey from a Google Sheet shared by link.
  • Summarise a study, find items, and look for mistakes, e.g. jumps to positions that don't exist, modules nothing leads to, or conditions that name items that don't exist. For this it also reads formr's documentation, example studies and a library of patterns (balanced randomisation, waiting rooms, live feedback, personalised emails).
  • Make test users (with links for your browser), move them on or to a position, and read their logs and what they recorded.
  • Upload and delete a study's files.

Things to ask, for example:

  • Summarise my diary study and check it for problems.
  • After the intake survey, add a daily diary for 14 days with a reminder email at 8 pm.
  • Make two test users, take one to the end, and show me what it recorded.

Check what it made on the study's Edit Run page before participants start. It can be wrong in ways that look right.

Your participants' data

By default, the MCP server reads test users only: real participants' sessions, results and logs are not passed to the assistant, whatever scopes you allowed. Nor can the assistant delete real participants' answers then: it can't remove survey items they have answered, and it can't delete a study they have taken part in or change its deletion date (Expires On). Do that in formr's admin. This instance's administrators can allow more, for everyone. Ask the assistant whoami to see which applies here.

What the assistant reads (your studies' modules, survey items, R code, test data) goes to the company that runs it, under your agreement with that company. Your studies' R secrets reach it by name only, never their values.

Changing a live study

Its changes reach participants as changes made on Edit Run do:

  • Participants stay where they are on every module it keeps, also when it changes that module's text or settings.
  • A module it moves takes its participants along.
  • Removing a module that real participants (not test users) are at needs your yes, and the assistant asks you first. Those participants then go on from whatever now stands in that place.
  • If the study changed in formr meanwhile (e.g. on Edit Run), formr refuses its change, and it reads the study again.
  • A survey's items change only where it sends different ones, and only with survey:write.
  • Removing, renaming or re-typing items that real participants have answered is refused, unless your administrators allow it. Then it needs your yes, too, and formr saves the results in a backup first.

Your connections

Account → API Credentials lists each app you connected under Connected apps, with its scopes and runs. Edit changes them, from the app's next request on. Delete ends the connection at once. A connection not used for 30 days ends by itself, and every connection ends when your account loses API access. Connecting the same app again makes a new connection.

Other apps

formr signs in apps that publish who they are at a fixed address (a client metadata document). Claude, Claude Code, ChatGPT, Codex and VS Code do. Apps that register anew with each server instead, such as Cursor and Gemini CLI (in November 2026), can't connect this way. The operators of the instance can enable another app that publishes such a document.

An assistant that can run code on your own computer can do without the MCP server: give it an API credential of yours, and it can call the API itself, e.g. with formr's R package. It then reads whatever the credential allows. With session:read or data:read that includes your real participants, so use a credential without these for an assistant that should only build studies. Keep the credential's secret as you would a password, and give it only the scopes and runs it needs.

If something goes wrong

  • "This formr instance has no MCP server": its operators haven't enabled one.
  • formr says your account has no API access: it needs admin level 2, see Account → API Credentials.
  • "The app's description … is not one formr can use", or the app can't register: formr doesn't sign in that app, see Other apps.
  • A tool is refused for lack of permission: the connection lacks that scope, or that study isn't among its runs. Edit it under Account → API Credentials, or ask the assistant whoami to see what it may do.
  • It sees no participants: by default it sees test users only (above).
  • The app keeps asking you to sign in: the connection was deleted or ended after 30 days, or your account lost API access. Signing in again makes a new one.

Help


Where to get help

If you're a participant in one of the studies implemented in formr, please reach out to the person running the study.

If you're running a study yourself, there are several places to look for help.

  • this documentation is a good start, just click on any of the tabs above. The Guides answer the questions we get asked most.
  • There is a Wiki on Github. You can find a number of HowTos there and contribute yourself, e.g. how to send texts. We're moving the ones that still hold into the Guides.
  • You can ask (and answer!) questions in our Github Discussions forum for community support. Previously, we used a mailing list, but spam made it unusable. You can still browse it.
  • If you find a bug, this is the place to describe it (preferably in a way that allows us to reproduce it, but we're also accepting Yeti reports).
  • If something is wrong with this formr instance itself (it's down, or you need the rights to create studies), ask the people who run it.
  • Please don't email formr's developers for general support unless you've bought support from them. If you've found a security problem, don't post it publicly. Report it privately on GitHub (Security → Report a vulnerability in formr's repository).