Race Track Custom Gravity

I built a custom track generator for a racing game. Works fine but I want to add custom gravity that goes according to the track (like if I want the racers not to fall of the track if I tilt it 90 degrees or make loops).
What’s the best way to do that?