Carrier Log in
← All tutorials

Variables, from the start

What a variable is, and three variables to start with: a constant, a random pick for each participant, and a score from answers. Each one shows in a page and in the export.

  1. The Variables manager

    Variables, in the builder toolbar, opens the manager. Your variables are on the left. The variable that you edit is in the middle.

    + New variable adds a variable.

    The key is the name that you use. It must start with a letter and contain only lower-case letters, digits and underscores. The manager does not check the key. Deploy does not accept a key that does not obey the rule.

    The kind sets the other fields in the editor.

    Apply changes only keeps your edits in the builder. Deploy saves them.

    The first variable here is a Constant. It has one value, the same for all participants. Thus you can change a place name in one location.

    town, a constant: Port Ellis.
  2. A random draw

    Random pick gives each participant one of its values. Carrier picks the value one time, when the participant's run starts. This is after the name and the global pre-survey (if there is one), and before the first chamber. The value stays the same if the participant reloads the page.

    The weight of each value sets how frequently Carrier picks it. Here, all weights are 1, so each value has the same chance. A weight of 0 never gets picked.

    Each pick is independent. Thus the groups are approximately equal, not exactly equal. For balanced conditions, use a counterbalance variable (see Two conditions, counterbalanced).

    The picked value goes to the participant's browser. Do not think that it is hidden.

    plan_option: the ferry terminal or more berths.
  3. A score from answers

    An Expression calculates a value from other values.

    In the Formula shape, + Add input names a source. Here, the sources are two rating questions from the chamber before this chamber. The formula combines the names with + - * /, brackets and functions such as round, min and max.

    Set the data type to number for a score. Carrier calculates the value again each time one of the answers is saved.

    Make the questions required. If an answer is missing, the result is not a number.

    For if-then rules, use the Conditional shape.

    harbour_score = ferry + market.
  4. Into a page

    In the editor of a page, Insert variable writes a token such as {{var.town}}. The participant sees the value.

    Carrier fills in the values when the page opens. Thus ask the questions in an earlier chamber, as here. If a value changes later, a page that is open does not change (see Instruction pages that use answers).

    The three variables in one line.
  5. What participants see, and the export

    The participant gives the ferry a rating of 4 and the market a rating of 2. Then a page shows the town, the picked option and a score of 6. After a reload, the page shows the same option.

    In the export, the Participants sheet has a var. column for each variable: var.town, var.plan_option and var.harbour_score. Each column has the value for each participant.

    Other kinds use these ideas:

    • An alias gives a name to a survey answer (Match participants on a survey answer).
    • A counterbalance balances conditions (Two conditions, counterbalanced).
    • An LLM-processed variable lets a model read an answer (Read an open answer with AI processing).
    Answers are given; the page shows them; a reload keeps the picked option.