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.
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.
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:
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.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.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.
To run formr on a server of your own, see Running your own instance in the Guides.
Answers to the questions we get asked most. Pick a question, or read a whole guide.
New to formr? Start here:
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.
If only one study is affected, it's usually the study, and you can fix it yourself. These tell you more:
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.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).
Write to the people who run this instance and say:
If you've found a bug in formr itself, the Help tab says where to report it.
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.
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:
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).
An export takes your study's modules, surveys and most settings along. Participants and their data stay behind.
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.
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.
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.
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:
join = FALSE and combine the tables yourself.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.
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.
formr sends your study's emails through a mail account of yours. Under Mail Accounts, click Create New Account:
smtp.example.org and 587. Tick Use TLS for port 587. For port 465, untick it and formr uses SSL.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.
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:
email_skipped_user_active). The box is meant for emails after a Pause.email_skipped_user_disabled).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).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:
{{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.
The Recipient field of an Email module takes one of these:
email item, in any survey of this study.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.'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.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:
intake with an optional email item called email_address.is.na(intake$email_address).intake$email_address with {{login_link}} in its body.followup.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.
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:
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:
confirm_deletion.*** for addresses.FALSE is asked again every 10 minutes, also after a day.?_new_session=1 (When formr mixes them up).XXXXX (XXX before).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.
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.
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.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.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:
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:
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 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:
The usual causes:
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.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.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.
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.
{{settings_link}}) shows their user code, which they can send you (Deleting one participant's data).consent.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.
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:
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.
Find the participant's user code in your study's Users list and click the bin in their row.
{{settings_link}} puts it in an email (see Placeholders).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:
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.
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:
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.
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.
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.{{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.{{logout_link}}, or the button on their settings page), the browser forgets them. Their answers stay saved, and their own link brings them back.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.
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:
request_cookie item on your first page, so participants allow the cookie that the lifetime needs.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:
?_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.{{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.{{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.
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).
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.
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:
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.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.
intake with a get PROLIFIC_PID item named prolific_pid.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.
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.
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.
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.code. formr reads code as the participant's user code, and your participants would see "Invalid user code" (see Codes of your own).get item can only read a parameter whose name is made of letters, digits and underscores.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.The panel needs to know who finished. You have the following options:
?cc= and your study's completion code). formr sends participants there as soon as they reach it, and the panel records them as finished.`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 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.
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).
formr checks a showif when the page opens, with the answers given so far.
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.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).
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:
hidden item mom_alive with the value demographics$mom_alive,conflict ("Did you have a conflict with someone today?", 1 = yes),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.
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.
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, 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.
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 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:
intake, with the consent form and an email item for the participant's address.19:00. Its Text to show while waiting says "Thank you! We'll send you the link to the next diary at 7 pm."{{login_link}}.120 minutes. Participants who show up before then move to position 60.{{login_link}}.diary, with Start editing within 120 and Inactivity Expiration 30 in its settings.nrow(diary) < 14.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.
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.
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.
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:
intake, which asks participants to install the study and allow notifications (Making your study an app).1800.esm, with Start editing within 30 and Inactivity Expiration 10.nrow(esm) < 35.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:
| type | name | label | choice1 | choice2 |
|---|---|---|---|---|
rating_button 1,7,1 | mood | How do you feel right now? (very bad to very good) | ||
mc_button | alone | Are you alone? | yes | no |
text | activity | What are you doing? | ||
submit | done | Send |
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:
TRUE or FALSE is run again every 10 minutes, so a sample() in it draws a new number each time.nrow(esm) counts prompts, answered or missed (Counting the days).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:
self, in which participants describe themselves and give their email address.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:
peer. Its first row is an item of type get target called target, and the rating items follow.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.
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.
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.
You have the following options:
peer.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.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.
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.
To stop letting people in once 300 have finished, check how many have reached the end before a newcomer starts the main part.
demographics.questionnaire.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.
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.
intake. Its last row, after the last submit button, is a calculate item called condition with the code below as its value.intake$condition == "training". If it's true, it skips forward to Pos. 50.control_task.TRUE, so it always skips forward to Pos. 60.training_task.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:
calculate items only work in classic surveys, not on v2.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:
wellbeing with the item life_satisfaction (1 to 7).```{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.
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.
ratings.waiting, with a note ("Waiting for the others. This page reloads itself.") and a submit 10000 button.TRUE, so it always goes back to Pos. 20.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:
testing = FALSE before the real thing.formr_api_session_action() (see Moving participants on).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.
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.
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).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.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.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.
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.
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.
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.
daily appear by itself.{{settings_link}}, also in a new study's footer), participants can turn notifications off and on again.You have the following options:
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.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.
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.
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.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.
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.
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:
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).
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.
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.
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:
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.The classes are described under CSS classes.
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).
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.
?_new_session=1&rated=P1 becomes ?code=…&rated=P1, so your survey can still read rated.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.
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}}{{login_url}}[Start today's diary]({{login_url}}).{{login_code}}<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}}{{settings_url}}{{logout_link}}{{logout_url}}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.
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).
`r demographics$first_name`. Without a title, the notification is titled "Notification". A very long message is shortened.0 shows none.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.
Using an SMTP account (most email addresses come with one) that you can set up in the mail section, you can send emails to your participants, their friends or yourself. Using the tag {{login_link}}, you can send participants a personalised link to the study. You can also use {{login_code}} to build links of your own with the user code, with the address in angle brackets (see Placeholders). To invite peers to rate this person (informants), see Peer ratings. Many providers don't let you send automated email through their SMTP server, and Gmail and Outlook usually don't work. The email guide says which accounts do.
Under Account, choose which of your email accounts sends the email (if you don't, it's the first one). The body can use all placeholders, the subject none. If you tick Send e-mails only when cron is running, the email only goes out when formr reaches it in the background, e.g. when a Pause ends. Participants who reach it while they're on your study's pages, e.g. right after a survey, move on without it.
A simple one-shot survey with feedback. Let's say your study contains
email_address).
big5$email_address.
A participant fills out your survey. After completing it, they see the feedback page, which contains a bar chart of their individual big 5 scores. Before they see the page marked by the stop point, an email containing the same feedback is sent off to their email address - this way they get a take-home copy as well.
A simple one-shot survey after which you receive a notification.
'youremailaddress@example.org'. Note the single quotes, they mean that this is a constant.
A participant fills out your survey. After completing it, they see the thank you note at pos. 30. Before they see the page marked by the stop point, an email is sent off to youremailaddress@example.org - this way you (or whoever's email address you use here) would get an email notification for every participant. This might be helpful in longitudinal surveys where experimenter intervention is required to e.g. set up a phone interview, in an assessment context when you want the scores to be automatically generated, or in a clinical study where you want to do a structured interview after a screening task.
See the Knitr & Markdown section to find out how to generate personalised emails, which contain feedback, including plots. In the next section, you'll learn how to use the email module for invitations in a diary study.
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.
A simple diary. Let's say your study contains
nrow(diary) < 14 and the instructions to jump back to position 20, the pause, if that is true.
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).
But you can also make a loop that doesn't involve user action, to periodically check for external events:
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.
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).
A Pause has these fields:
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.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.
Let's say your study contains
depression$suicidal != 1. If the person is not suicidal, it skips forward to pos 40.
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.
Let's say your study contains
optimism$pessimist == 1. If the person is a pessimist, it skips forward to pos 50.
TRUE, so it always skips forward to pos 60.
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.
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.29.5 and 30.4 both mean position 30. Rounding comes first, so 1.9 becomes 2 and jumps.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.
Let's say your study contains
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).
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}).
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.
Only you and test users can access the study. Everyone else sees your service message. Use it while you build and test.
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.
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.
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.
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.
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.
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.
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.
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.
example_diary_intake, example_diary). The diary guide explains it.example_esm_intake, example_esm). See Several prompts a day.friend_list, friend_rate).data_quality and agent_probe items, as classic surveys (dq_weekend_consent, dq_weekend_study) or v2 forms (the same names with _v2).bot_check and turnstile added (bp_weekend_consent, bp_weekend_study). It needs Turnstile set up on this instance.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.
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.
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.
the date on which formr deletes the data participants left in your study. See below.
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.
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.
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.
Markdown shown at the top of every page of your study, and in link previews. Optional.
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.
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.
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).
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.
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.
what participants may and may not do in your study.
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.
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:
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 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.
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>
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.
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.add_to_home_screen, push_notification, …) to a survey, and Push notification modules to the study.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."
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.
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).
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.
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 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:
__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.
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:
number 1,130,1, or the name of a choice list, e.g. mc agreement.
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.
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.
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).
* 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 !.
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).
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.
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.
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:
An instruction comes first, then items 1 to 4 in random order.
| name | block_order | item_order |
|---|---|---|
| instr | 1 | |
| item_1 | 2 | |
| item_2 | 2 | |
| item_3 | 2 | |
| item_4 | 2 |
Blocks A and B come in random order. Inside each block, the items keep their order.
| name | block_order | item_order |
|---|---|---|
| item_1 | A | 1 |
| item_2 | A | 2 |
| item_3 | B | 1 |
| item_4 | B | 2 |
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.
| name | block_order | item_order |
|---|---|---|
| item_1 | A | 1 |
| item_2 | A | 1 |
| submit1 | 2 | |
| item_3 | B | 3 |
| item_4 | B | 3 |
| submit2 | 4 |
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.
| name | block_order | item_order |
|---|---|---|
| item_1 | A | 1 |
| item_2 | A | 1 |
| submit1 | A | 2 |
| item_3 | B | 1 |
| item_4 | B | 1 |
| submit2 | B | 2 |
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).
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.
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.
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.
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.
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).
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.
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.
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
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:
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.
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.
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.
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.
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:
Two more examples, an invitation that's open for 7 hours in both:
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.
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 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 |
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.
showif or for dynamically generating item text have been given.
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.
text 100 defines the maximum number of characters that may be entered.
<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.
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.
A-Za-züäöß.;,!: ), no numbers.
{{login_link}} and go on only with those who open it.
0,100,1. The step can't be 0.
0,100,1. Works in classic surveys and v2 forms.
2013-01-01,2014-01-01 or -2years,now.
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.
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").
yyyy-mm. Stored as the first day of that month (2024-05-01).
yyyy-Www (e.g. 2024-W05) and stored as text.
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 but instead of the text appearing next to a small button, a big button contains each choice label
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.
mc_button with the ♂, ♀ symbols as choices
Europe - Berlin for Europe/Berlin, America - New York for America/New_York.
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.
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.value).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 2 or bot_check 3 makes the puzzle two or three times the work. Without a number, the instance's setting applies.verified, nothing that identifies the participant.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 non_interactive visible, participants see Cloudflare's small box with a spinner and its logo while it checks.
unavailable is stored, so an outage at Cloudflare doesn't close your study. An optional managed item only records.
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.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.turnstilechallenges.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.blocked and bot more often.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).
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
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.
mod_remoteip). Otherwise you store the proxy's address.
server HTTP_USER_AGENT.
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.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.
(item1 + item2) > 100 to add further requirements.
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.
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.
installed (classic, the page was opened from there or the browser's install dialog succeeded), added or already_added (v2)promptednot_started (classic), not_requested (v2, the button hasn't been used)declined or failed (classic), not_added (v2)no_support or unsupported_browser, and in v2 not_prompted (the browser offered no install prompt)
not_requested not asked yetios_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 errorfunctional_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.
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:
mc_width… has no effect there).
square square80. In classic surveys, square70 gives 60 pixels.
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.
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.
For your participants:
submit items still end each page.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.
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:
| name | type | showif | value |
|---|---|---|---|
older | hidden | ifelse(demographics$age >= 30, 1, 0) | |
mood | mc mood_scale (choices 1 to 5) | ||
mood_why | textarea | answered(mood) && mood <= 2 | |
back_pain | mc yes_no | older == 1 | |
done | submit |
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.
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:
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:
| Setting | Default | What it does |
|---|---|---|
| Offline queue (Enable offline queue) | on | Keeps 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) | off | Lets participants go back to earlier pages. While it's off, the browser's back button doesn't take them back either. |
| Layout | Default | Default or Solo, see Layouts. |
| Participant language | en | A 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 labels | empty | Your 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 valueIn v2, the two columns follow two rules:
showif is JavaScript. It runs in the participant's browser, again whenever an answer changes.value is R. Anything other than an empty cell or a number runs in R on the server.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, FALSE | true, 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") |
| Helper | What 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.
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 itemsv2 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:
hidden item with the same value (see below).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.
sticky, another survey's data, a sample()) is computed once, so a random group isn't drawn again.TRUE or FALSE, so return numbers, as ifelse() does above.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.
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.
Layout changes only how pages are presented, so you can change it while your study is running.
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.
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.
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.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.
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.
form_v2_offline_blob_max_mb).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.
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:
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.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.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.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.
For a survey that is already collecting data:
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.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.$). On a v2 form it runs once, when all pages are in the browser (see JS).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.
The administrator of a formr server can change these. Details are in documentation/form_v2_upgrade.md in the formr repository.
| Setting | Default | What it does |
|---|---|---|
form_v2_enabled | false | offers v2 for new surveys and Move to v2. Surveys already on v2 keep working without it. |
form_v2_rate_limits | 30, 90, 10, 20 per minute | per 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_ttl | 300 s | how long an R result is reused for the same answers |
form_v2_offline_blob_max_mb | 10 | the largest file (in MB) a page can take into the offline queue |
bot_check_* | see form_v2_upgrade.md | difficulty, memory, time, lifetime and secret of the bot_check puzzle |
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.
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.
# 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  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.
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".```{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
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.
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.
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.
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.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
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
time_passed(hours = 7)
next_day()
in_time_window(time1, time2)
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).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.
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:
mean_score(diary$headache), instead of reading diary inside the function.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.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.
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))
.formr$secret_api_key. A reference you build while the code runs, e.g. .formr[[paste0("secret_", name)]], finds nothing.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).
The following designs and many more are possible:
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.
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.
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":
dashboard, cron-2026). It must be unique in your account, and internal is taken.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.
| Scope | Lets the credential |
|---|---|
user:read, user:write | read your profile, change it |
run:read | list your studies, read their settings and units |
run:write | create studies, change their settings and units |
run:delete | delete studies. Until v2.0.0-rc13, run:write allowed this, so credentials that had run:write then have both. |
survey:read, survey:write | read surveys, upload, change and delete them |
session:read, session:write | see your participants and where they are, add participants and move them on |
data:read | read your participants' answers |
file:read, file:write | list 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.
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:
colleague-download.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.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.
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"
}
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:
| Call | Scope | What it does |
|---|---|---|
GET /v1/user/me | user:read | your profile |
PATCH /v1/user/me | user:write | changes it |
GET /v1/user/token | none | what the token is: its account, scopes, expiry and runs |
GET /v1/runs | run:read | lists your studies |
POST /v1/runs/{name} | run:write | creates a study |
GET /v1/runs/{name} | run:read | a study's settings |
PATCH /v1/runs/{name} | run:write | changes them |
DELETE /v1/runs/{name} | run:delete | deletes the study |
GET /v1/runs/{name}/structure | run:read | its units |
PUT /v1/runs/{name}/structure | run:write | changes its units |
GET /v1/runs/{name}/sessions | session:read | its participants and where they are |
POST /v1/runs/{name}/sessions | session:write | adds participants |
GET /v1/runs/{name}/sessions/{code} | session:read | one participant |
POST /v1/runs/{name}/sessions/{code}/actions | session:write | moves a participant on, and more |
GET /v1/runs/{name}/unit_sessions | session:read | every unit each participant reached |
GET /v1/runs/{name}/results | data:read | the answers to its surveys |
GET /v1/runs/{name}/files | file:read | its files |
POST /v1/runs/{name}/files | file:write | uploads a file |
DELETE /v1/runs/{name}/files/{file} | file:write | deletes a file |
GET /v1/surveys | survey:read | lists your surveys |
POST /v1/surveys | survey:write | uploads a survey, new or changed |
GET /v1/surveys/{name} | survey:read | its items |
PATCH /v1/surveys/{name} | survey:write | changes its settings |
DELETE /v1/surveys/{name} | survey:write | deletes it |
A credential restricted to some runs lists only those, and only the surveys that are part of them.
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.
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.
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.
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):
action | What it does |
|---|---|
advance | ends 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_position | sends 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. |
execute | runs 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_external | ends 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_testing | makes 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.
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.
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.
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.
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.
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.
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:
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.run_unit_id is new. That includes a copied unit: leave its run_unit_id out.run_unit_id but changed to another type, or to another survey, becomes a new unit.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.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.
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.
# 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"}'
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).
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:
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.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.
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.
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).
Add the MCP server's address to your app. The app then sends you to formr to sign in.
| App | How |
|---|---|
| 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.
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:
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.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.
run:delete). Studies real participants have taken part in are kept, unless your administrators allow it.Things to ask, for example:
Check what it made on the study's Edit Run page before participants start. It can be wrong in ways that look right.
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.
Its changes reach participants as changes made on Edit Run do:
survey:write.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.
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 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.