Step 1: Step One:
Yes, seriously. As soon as you realize you have stumbled onto some quicksand, lie or sit on your back. This works because it distributes your weight more evenly and slows down your sinking.
Step 2: Step Two:
As soon as you are laying back, remove any excess gear. This means backpacks and, if possible, footwear. Throw this gear safetly onto dry land. You now weigh even less and are ready to make your escape...
Step 3: Final Step:
Slowly shimmy to the nearest patch of dry land. Try to slip across the quicksand rather than push against it, and don't make any sudden movements. If your hands or feet are submerged pull them out carefully. Stay on your back and don't try to stand up until you are well onto dry land. Do a victory dance.