Answer:
Positive reinforcement is one of the best ways to train a dog. This may be treats, such as a biscuit, or affection, like a belly rub. There's also giving them a new toy, or taking them on a walk even. Most trainers have these tools called clickers. They get a dog's attention and keep it, refocusing them if they wander off mentally.
Not all trainers train their dogs to stay the same way. More popular ones may give the command "Sit!", which sometimes isn't very effective. I personally trained my dogs with a type of sign language. One finger up for "sit", and two for "stay". Full hand is "down" or "wait". As I said, many different ways of training.
If a dog does not respond to positive reinforcement, there is negative reinforcement, but it is seriously frowned upon. This could be a water bottle or receiving no treats. Some people take this too far, however.
The best way to train a dog to stay is to be patient with them, use positive reinforcement, and to understand. They're a dog, they're bound to be distracted, just like a child. To refocus them, snap your fingers or whistle, and if need be, call their name. Don't expect them to learn it all in one day: all dogs have different personalities and learning capabilities. One dog may pick it up quick, while it may take another month to learn, just like humans.
You also have to take into consideration age and history of the dog. These are two very important factors in training, as if a dog is used to being spoiled rotten, positive reinforcement most likely won't help. If the dog is a young puppy, they're going to want to learn and explore instead.
I hope this helps, sorry for rambling.