How to randomise users into two groups

From Lifeguide Wiki
Jump to: navigation, search

Randomisation Example: Splitting end-users into two groups

A study exploring the perspectives of taking up smoking

A demo of this example is available at the following address:

This example requires end-users to be automatically randomised into one of two groups; group 1 will receive questions about the uptake of smoking alongside images of health messages whilst group 2 will receive only the questions. If this were a real study the purpose of this might be to see how the presence of the images might affect the answers given.

show welcome

• Shows end-users the first page of the intervention which has been given the unique name welcome.

after welcome if (loadvalue(username, "group") = "group1") goto q1p1

after welcome if (loadvalue(username, "group") = "group2") goto q2p2

• This logic is very important because some end-users may click on the browser back button on page q1p2 or q2p2 and then try to go forwards again. This logic will stop end-users from being randomised again if they click on the back button once they have been randomised. group1 and group2 are saved using the savevalue function as shown further down below.

after welcome if (randomnumber (0,1) = 0) goto group2

• This is the command that randomises end-users into one of two groups and then sends them onto the right section. So a more detailed explanation of this logic sees that after the end-users have moved past the welcome page they will be automatically assigned to one of two groups using the command randomnumber (0,1). Those in the ‘0’ group will then be sent to the section that has been labelled group2

NB: It is important that you do not repeat the logic command for group 1 as otherwise that will not be split evenly.

begin group1

show q1p1

savevalue(username, "group", "group1")

• Saves the name of the group as group1.

show q1p2

• The other 50% of end-users will be sent to the section for “group1”. This consists of two pages of questions named q1p1 and q1p2.

• It is important for this section to come before the section that the rest of the group has been sent to in the randomisation logic. If not the logic will simply move onto the next line of commands and send all end-users to that group.

• The last page on each section will either need a jump button to a final page that users of both groups can see (as has been done on q1p2 in this example) or no button at all. If this page had a next button, end-users of the first group will then go straight into the section for the second group.


• Remember that whenever you start a section you must remember to end it with the command end (this is explained in the logic dictionary)

begin group2

show q2p1

savevalue(username, "group", "group2")

• Saves the name of the group as group2.

show q2p2


• Shows the pages for group2 that only those randomised to 0 will see.

show final

• Shows all users the final page for the intervention.