If your dog makes messes on the floor, the easiest thing to do is to start from scratch. Crate training is a very effective tool because it gives the dog a smaller space to claim as their own, tapping into that instinctual desire to not make a mess where they sleep.
If crate training is out of the question, you should confine the dog to a single room and pay close attention to them. Create a routine that allows the dog to go to the bathroom at the same time every day, and when the dog does their business outdoors, make sure to praise them profusely. On the flip side, do not get angry if your dog makes a mess inside.
Attempt to startle them with a sharp noise, such as clapping your hands, and then take them outside immediately so they begin associating outdoors with relieving themselves. Just remember that punishing your dog for making a mess will have no impact. The dog is incapable of understanding why they are being punished before they fully understand that they are not permitted to go to the bathroom indoors.
Additionally, it is a good idea to have your carpets thoroughly cleaned to remove any pet odor that may linger. Conventional cleaners tend to just mask the smell to human noses. Dogs, on the other hand, can still smell their markings and will return there later. If you have more than one dog, they may even attempt to mark over the top of each other, leading to a cycle that can be hard to break.

