Put it on the track and apply your choice of AC or DC- the motor is universal. It will reverse direction when the bumper impacts a track bumper or other convenient object.
Note that DC polarity does not matter and that track power interruption will have no effect on the direction.
Thanks for the information. Does the trolley reverse when the DC polarity is reversed ?