Experiment memory

Experiment memory is a simple storage system which allows you to store and retrieve simple string values for an experiment.

This can be useful for storing values which change throughout the experiment, such as a running count of participants assigned to a specific condition, or the current development stage of an experiment.

Format of experiment memory

Experiment memory is formatted as a lightweight JSON object, with keys and values represented as strings. Keys are case-sensitive, at most 128 characters, and cannot contain / or \. Values are strings, and can be up to 2 MB. A single experiment can store up to 500 keys.

For example, say you had a running memory of how many participants have been assigned to two condition groups; your experiment memory might look something like this:

{
  "ParticipantsInConditionA": "15",
  "ParticipantsInConditionB": "10"
}

Setting and retrieving memory values

Memory values can be set and retrieved programmatically from Unity. Use the following API calls to manage your experiment memory:

  • VERASessionManager.SetExperimentMemoryKey: Set a new memory key, or replace the value of an existing key

  • VERASessionManager.GetExperimentMemoryKey: Retrieve the value of a specific memory key

  • VERASessionManager.AddToExperimentMemoryKey: Increment (or decrement) the value of a specific memory key by a given amount (for example, add one to a running total)

  • VERASessionManager.ClearExperimentMemoryKey: Delete a memory key and its value

There is also a “Memory” button available on the Experiment Management page, which allows you to view, manually edit, or download all memory values for an experiment.

Example usage

Say you had a running count of how many participants have been assigned to two condition groups, group A and group B. By using these running totals, you plan to balance participants between the two groups as the experiment progresses.

At the start of your experiment, you could first fetch the current memory values for each group:

VERASessionManager.GetExperimentMemoryKey("ParticipantsInConditionA", onSuccess: (value) => {
  participantsInConditionA = int.Parse(value);
});
VERASessionManager.GetExperimentMemoryKey("ParticipantsInConditionB", onSuccess: (value) => {
  participantsInConditionB = int.Parse(value);
});

You could then balance based on these values: