I see many questions on housebreaking. I have extensive, successful experience, but can't explain what has worked for me with many puppies in 1000 characters.
Much of housebreaking is not training the puppy, but making it easier for your puppy, you, and your carpet while its body to catches up to its instincts. At around 8 weeks when the puppy goes to its new home, the time from when it realizes it has to go, and when it can't wait any longer is a matter of seconds. Only time will fix that. You can hardly be expected to be attentive enough to avoid all accidents. There is no sense punishing the puppy for your inattention. It is not fair to punish you either, but you still have to clean it up if you didn't have the puppy outside in time.
Housebreaking starts before you get home with the new puppy. If you don't have a crate, buy one. I prefer the more enclosed, den like plastic ones. Skip the bedding. At first it gets wet, and later it can be chewed into choking hazards. A wire grid in the bottom will help keep the puppy up out of accidents at first. They are available with the crates, but expensive and hard to find. A piece of closely spaced wire closet shelving from a home supply place is cheaper. I am now using a plastic vegetable bin with plenty of holes drilled in the bottom. It helps block off part of the crate for the smaller puppy. If you already have a metal crate, covering it may help. Just make sure you use something the puppy can't pull in and chew. Dogs that start out in crates as little puppies, accept them very well. Never leave an unattended puppy loose in the house. If nobody can watch it, put it in the crate. I suggest letting the dog have its crate all its life. A crate needs to be just big enough for a dog to stretch out in.
Choose a command and spot you want it to use. The less accessible to strays, the less chance of serious disease. If it is a female, choosing a non grassy spot will avoid brown spots later. When you bring it home, take it to the spot and give it the command in a firm, but friendly voice. Keep repeating the command and let the puppy sniff around. Sometimes you need to walk it around to stimulate its body to eliminate. If it does anything, praise it. Really let it know what a good dog it is and how much you love it, and maybe a treat. Note, being out there not only means you can praise it, but it also keeps it from being snatched by a hawk. If it doesn't go, take it inside and give it a drink and any meals scheduled. A young puppy will need to go out immediately afterward. Go to the spot and follow the above routine. Praising it if it goes is extremely important. If it doesn't go, try walking around to stimulate the body to eliminate. They can only walk and hold it so long. If that still doesn't work, take it back inside and put it in its crate and try again soon. Do not let it loose in the house until it does go.
At first it is your responsibility to know and take the puppy out when it needs to go. It needs to go out the first thing in the morning, after eating, drinking, and sleeping. If it quits playing, and starts running around sniffing, it is looking for a place to go. Take it out quickly. You will just have to be what I call puppy broke until it is a little older. How successful you are depends on how attentive you are.
By the time most dogs are about 3 months old, they have figured out that if they go to the door and stand, you will let them out. The praise slowly shifts to going to the door. Some people hang a bell there for the dog to paw. If your dog doesn't figure this out, try praising it and putting it out if it even gets near the door. When you catch it in the act, give it a sharp ''Ah, ah, ah!'' and take it out. Clean up accidents promptly. I mostly keep the little puppies out of the carpeted rooms. Still I need the can of carpet foam sometimes. First blot up all the urine you can with a dry towel. Keep moving it and stepping on it until a fresh area stays dry. A couple big putty knives work well on bowel movements. Just slide one under it while holding it with the other. This gets it up with a minimum of pushing it down into the carpet. This works with even relatively soft ones, vomit, dirt from over turned house plants, or anything else from solids to thick liquids. Finish up with a good shot of carpet foam. Note, do not let the puppy lick up the carpet foam. Once the dog is reliably housebroken, your carpet may need a good steam cleaning.
Many people strongly strongly push cleaning up all evidence of past accidents. I am slower to suggest that. Dogs will return to the same spot if they can find it. When you see one sniffing the spot, that is your clue to run it out.
This can be applied to older dogs too. Biggest difference is the longer time after eating or drinking before they are ready to relieve themselves. If a dog has been living where it could keep its living space clean, it should quickly catch on. The important part will be teaching it that if it goes to the door, you will let it out. It will be much more difficult if the dog was forced to live in its filth. You will need to learn to read the dog and learn its schedule, and when it needs to go out. Keep it in sight, closing doors and setting up gates. Some people even leash the dog to themselves. I have used a tie down at my computer desk.