Step 1: Focus. Don't let yourself get distracted by something, including your own social anxiety. If you're really in the moment, you won't forget so easily.
Step 2: Repeat their name back to them immediately. Saying something like, "Nice to meet you, Tom" really helps your brain process it.
Step 3: Associate it with something meaningful to you. Like that you have a "tom cat," or that your favorite actor is Tom Hanks.
Step 4: Form a mental image between the person and your association. Like if their name is Victoria and it reminds you of Queen Victoria, picture them wearing a crown. The sillier the better, because silly things are more memorable.
Step 5: Connect their appearance to their name. Like maybe Victoria is wearing a V-neck sweater. That "V" alone might help you remember later on.
Step 6: Keep repeating their name. Say it again in conversation a few minutes later . . . then again as you're saying goodbye . . . and maybe even to yourself on the car ride home. Repeating it over and over helps make it a long-term memory.