Speaking as someone who's worked in cp stranger danger 'education' is now widely recognised as having done more harm than good for several reasons.
Parents not explaining what a 'stranger' is, as in just because they introduce themselves to you does not mean they're not a stranger, just because you've seen them in your neighbourhood does not mean they're not a stranger, just because you know them through their job does not mean you know they're safe (Ian Huntley?), just because they're a child doesn't mean they're safe (James Bulger? That's an extreme case but there have been other less known ones).
Parents not being clear that a 'bad person' is not a caricature, lots of paedophiles are good looking, well groomed and very charming. Not some version of the child catcher.
Most molesters are known and known well to not only the child but the family. They tend to groom the adults first. Position themselves as someone to be trusted.
So, bearing all that in mind what I taught my daughter was
Never go anywhere with anyone, even friends of mummy's without checking with mummy first. Anyone asks you to, for any reason, that's what you tell them. Then come find mummy (or nursery teacher or daddy) and tell them.
As she got older and was out and about with friends/alone, taught her how to walk safely (away from the road especially if a car slowed near her, but wide at corners so someone couldn't jump at her, not to be on phone or listening to music but be aware of surroundings).
If anyone ever did try and get her near a car to always stay at least 2 arm lengths away.
Now she's a teen, still encourage her to be aware of her surroundings. If she thinks she's being followed go into a shop or other safe public place and call me or if for any reason she can't get me the police, or if there's only houses one where children clearly live (toys in garden etc - yes not perfect but best of bad options).
From little taught her that she has bodily autonomy, the pants rule.
Also if anyone ever touches her inappropriately or tries to snatch her to shout, scream, scratch, kick, bite whatever to get away. Victims (including adults) who fight back are less likely to be further victimised, less likely to be moved to a more secluded area preferable to the attacker, more likely to frighten attacker off. I've done it myself.
If you really must go stranger danger route, do pants rule, staying away from cars and vans, telling mummy/daddy/trusted adult every time someone tries to get them to go somewhere else, teach them that a 'stranger' is anyone make female old young that she doesn't know really really well, that even 'nice' looking people can hurt you.
And despite this post my daughter is confident, sociable (talks to EVERYONE) and friendly.