I can't believe that I actually can answer a question on here...?
We learned this in basic obedience class! Dog offleash in fenced yard or house, and you have treats. Hold treat low down by your leg, and walk, saying "Follow me!" or "Stay close!" Dog will follow you (and the treat). Reward with treat periodically. Practice making turns and figure 8s and stopping while keeping dog by your side. This is painless, fun for dog, and helps to develop pup's habit of walking near your leg. (Trainer showed us the right way to hold treat...down next to your leg, and access to the treat is from BEHIND your hand...) Then you can add a "Sit" each time you stop, for fun.
Well, that's the way I was taught. I am sure different trainers have different approaches.
Rumo ~ rescue shepherd/husky mix