Hold a stick in your right hand and right click gates to register them. You must right click the interior face of the gate, similar to how you would light a nether ortal with flint & steel.
When you are done selecting gates, use /race setName to give the track a name.
Right click the target block with the stick to complete the track.
Video:
How to Race a Track
Right click a registered target block with an empty right hand to enter race mode.
Waypoints will appear to show you the way.
The lap timer starts when you enter the first gate.
A lap is recorded when you reach the first game again.
The leaderboards for the track appear in the top-right corner of the screen.