Multiple stimulus presentations and tagging

I am attempting to build an experiment in which participants are pre-exposed to stimuli before a subsequent categorisation task.

During the pre-exposure phase participants will be presented with several blocks of 48 stimulus presentations in which a set 24 stimuli are presented twice each

The participants will be required to indicate whether it is the first or second time they have seen a particular stimulus. Therefore, I need the stimuli presentations to be randomly intermixed (i.e. rather than presenting all 24 stimuli randomly and then presenting all 24 stimuli randomly again it should be possible for two presentations of one stimulus to occur before the first of another)

Also, the paradigm would require a way to tag the stimulus presentations in such a way that during data processing the presentations which occurred first and the presentations which occurred second could be extracted out from one another.

Is this possible?