Conditional Branching based on random number

I am building an experiment in the Builder that I would like to run online. It will start with some questions using the Forms, and then move into the experiment proper.

The experiment will consist of a few blocks of trials wherein participants have to respond as quickly as possible to one category of images (say Category A, the non-targets) and withhold their response for a different category of images (say Category B, the Targets).

I need to create it so that participants are randomly assigned such that for some participants Category A images are the non-targets and Category B images the targets, while other participants have Category B images as the non-targets and Category A images as the targets.

If I were doing this in person, it would be a simple matter of creating two experiments in the Builder and changing the spreadsheets. But is there a way to do this online? To, perhaps, branch from the very start based on a randomly generated number for example, and the experiment would terminate after the completion of the branch?

edit: or to refer to the spreadsheets based on the number? For example, generate a random number between 0 and 1, round it to the nearest (down to 0 or up to 1), and then refer to spreadsheet0 or spreadsheet1 when doing the loops. Would that work, and if so how?

No, you should never duplicate experiments: that way lies only pain and ruin due to the chances of inconsistencies arising. You would instead either randomly allocate conditions in code as you suggest, or enter condition information manually via the subject info dialog box.

Online, you don’t have a manual option, so either you must use some custom JavaScript to control parameters, or via the site you are using for recruitment (such as Prolific), pass some custom parameter via the URL for your experiment to use:

https://www.psychopy.org/online/onlineParticipants.html#recruitingonline