I'm also doing a racer at the moment and I know this is a tricky one. But I guess there's several ways to do it.
You could use checkpoints placed around the map, and checking the distances to the checkpoints.
this thread has some info.
For my own game I'm checking if something is infront or behind each car by comparing angles of the car, and the track, if something passes them on either side positions are updated. Still working on it as it has some bugs, but it's more accurate.