Support Home Walkthrough: Embedded Data

Embedded Data

  • What is embedded data?
  • Storing Embedded Data
  • Showing Participants their Responses and Scores
  • Using Embedded Data in Branch Nodes
  • Using Embedded Data in the Task Script Tab
  • Advanced Scoring
  • Using Embedded Data with Manipulations and Branch Nodes

What is embedded data?


Embedded data is data collected about a participant's responses that can be used to alter the experiment (in real time) depending on their response. Essentially, embedded data is information you can ’carry’ from one part of your task or questionnaire to others within the same experiment.

It can be used to:

Note: Embedded data does not appear in your downloadable metrics


Storing Embedded Data


In the Questionnaire Builder

To embed data in the Questionnaire Builder, check the ‘Write to Embedded data’ option in the widget of your choice.

Note: This is not available for all widgets.

Image showing QB widget Key and Embedded Data response box

This makes embedded data retrievable by Branch Nodes in the Experiment Tree.

To Branch participants according to their answers, you would then need to configure a Branch Node in the Experiment Tree. Go here to learn more about how to do this.


In the Task Builder

To embed data in the Task Builder, go to the Embedded data settings within the 'Active Responses' menu below the Screen Preview.

Note: This is not available for all zones.

Identify which of the options you'd like to store as embedded data, and enter in the setting a name for the embedded data e.g. 'correct'.

Image of Static Embedded Data settings

This makes embedded data retrievable in other parts of the Task or Experiment.

Note:

  • ‘Total answer count’ also includes timed out responses.
  • ‘Incorrect answer count’ also includes data for which no correct answer has been set.
  • ‘Correct answer count’ requires you to set a correct answer.
  • ‘Store most recent answer as embedded data called (setting)’ is useful for branching at the experiment level based on a single response.

‘Store correct answer count’, ‘Store incorrect answer count’, ‘Store total answer count’ and ‘Store percentage correct answers’ require you to set a correct answer for each trial.


Showing Participants their Responses and Scores


In the Questionnaire Builder

To present participants with one of their previous answers, add a Rich Text widget to your questionnaire. In this widget, type $${your question key would go here}.

The answer will then appear in this space.

This can also be used to retrieve an answer from a task or another questionnaire; just add in the correct embedded data key/name.

Image showing Rich Text widget with score code


In the Task Builder

You can present participants with their score by creating a Rich Text Zone.

In this zone, enter the following: $${your embedded data key/name would go here}.

The embedded data value will then appear in this space.

This can also be used to retrieve an answer from a questionnaire or another task; just add in the correct embedded data key/name.

Click to view an Example of a Classic Task that uses embedded data to score.

Click to view an Example of a Sample Task that uses embedded data to score.

Using Embedded Data in Branch Nodes


Branch Nodes allow you to send participants down different experiment paths based on their Questionnaire answers or Task responses.

After you have stored your answer or score as embedded data, you need to add a Branch Node.

For your Branch Node to work correctly, it needs to know what data to search for, and who to send down each branch.

You will always need to set up a minimum of two branches, one of which is set to a specific response or range of values, and a default. The two branches, when combined, will then represent the full range of responses your participants can give, so that no participant becomes stuck at the Branch Node.

To set up your Branch Node, click on the Node.

Group is the label you give to your branch.

Property - This is your question 'Key', or the name you gave your embedded data within the Task Builder. This tells the Branch Node what question the branch refers to.

Rule and Value are the rules you set for the branch. 'Value' can be numeric, such as the number of correct responses, or the name of one of your response options.

Press the small plus button at the bottom of the screen to add in another branch.

Your default branch can be configured by inputting the Group and Property and checking the Default option box.

Once your branches have been set up, your Branch Node will be able to link to one node per branch, e.g. if two branches are configured, you can create two different task paths.


A common reason to use embedded data with a branch node is in order to reject participants who do not meet your experiment requirements. This could be because they don't fit into your target group, because they gave an incorrect response to an attention check, or, as in the example below, simply because they did not agree to your consent form.


Click to view an Example of an Experiment that uses performance branching.


Using Embedded Data in the Task Script Tab


You can also use embedded data in the Script Tab. In order to do so, you'll need to use the function gorilla.retrieve.

Here's an example script which adds your embedded data to your metrics: Save Embedded Data to Metrics task.

Once your embedded data is in your metrics, you can use this to add custom functionality to your task. You may want to use advanced scoring, or use embedded data to manipulate task flow. Take a look at our Task Builder Script Examples for ideas, or adapt one for your own use.

If you get stuck, you can always contact support, but please bear in mind that we offer limited support services on custom script. We do however offer a paid consultancy service for those who would like us to build them custom functionality. Contact us for a quote.

Advanced Scoring


In the Questionnaire Builder

You can use embedded data within the questionnaire builder to combine answers into scores, reverse score, and separate participants into high, medium or low groups. This is achieved by entering some javascript into the script widget.

Image of the Script Widget


Combining answers requires several stages. This example uses Likert scale questions.

  1. First, after checking the embedded data box, you need to ‘retrieve’ the embedded data so that the script widget can use the embedded data. Input the code:

    var response1normal = parseInt(gorilla.retrieve('response1', 4, true)); var response2reverse = 8 - parseInt(gorilla.retrieve('response2', 4, true)); This retrieves the embedded data ‘response1’ (question key for response 1) and ‘response2’ (question key for response 2).

    It makes the default value (if no response is given) 4, makes sure the answer is an integer, and names this transformed data ‘response1normal’ and ‘response2reverse’ respectively.

  2. Then you need to combine the scores. You can do this by averaging the scores for the variables response1normal and response2reverse, and naming this as a 3rd variable, score.

    var score = (response1normal + response2reverse) / 2;

  3. The next job is to store this new variable within embedded data so that we can branch participants according to it.

    gorilla.store('score', score, true); ‘score’ will now be the key we can enter into our branch node, just as you would with a question key.

  4. The last step is to store this data to metrics.

    gorilla.metric({ question_key: 'score', response: score, })

This data will now be uploaded under the column labelled response.

For further detail on how to use the script widget with embedded data, and how to separate participants into groups, see the Scripting in the Questionnaire Builder walkthrough.

Information on using embedded data within the questionnaire builder is also available here.


In the Task Builder

You can score in the Task Builder in a similar way, through the script tab instead of the script widget. Gorilla will automatically count the number of correct and incorrect answers for you if you set a correct answer and use the embedded data settings.

Check out the 'Using Embedded Data in the Task Script Tab' tab to see how to retrieve embedded data for use in the Script Tab. Remember to retrieve the embedded data at the right point - if you want to use specific text answers rather than just a percentage or count, you'll need to run a script at the end of every trial using gorilla.onScreenFinish

After you've retrieved your embedded data, you can use steps 2, 3, and 4, in the Questionnaire Builder example above to add your custom scoring.

If your scoring is more complicated, requiring if and else statements, please contact support or take a look at our Task Builder Script Examples for examples of where this has been used.


Manipulations and Advanced Experiment Branching


Manipulations and Spreadsheet Manipulations allow you to alter a single Task Builder Task in the Experiment Tree to create multiple conditions.

However, when embedded data is saved during these tasks, problems can sometimes occur (e.g in the below set-up).

Image of experiment tree showing advanced branching

If embedded data has the same name/key in each task repetition, the embedded data from current, future and past implementations of the task may combine, and this will interfere with your branch nodes and scoring accuracy.

However, you can avoid this by setting your embedded data keys/names as manipulations (see below).

Image of Embedded Data SourceImage of ED Configuration

This will allow you to set a unique embedded data name for each task node, from the Experiment Tree.

Image of Manipulation in Task NodeImage of Experiment Tree with Correct ED