It can be tricky if the dog had loose stools. First, sprinkle sawdust or cat litter on it. Now it will become easier to remove the waste to the maximum possible. In case of dog pee, first use a paper towel to soak up as much liquid as possible from the carpet. Do not use printed paper because its ink will leave stains on the carpet. If you want to use such a paper, first place a layer of thick white paper towel. Stand and stomp on the paper for several minutes. You will have to remove the wet papers and use dry papers again and again during the liquid soaking process until there is no more liquid to soak up. You can also use unused clean baby diaper for this purpose.
Now use tap water and a liquid detergent to remove the stain and smell. Do not use hot or warm water on carpet. Once you use water, you have to repeat the paper soaking process again to soak up all the liquid from the carpet. You can also use different types of dog wee cleaning products available in the stores. Know how to clean dog wee and keep the required products at home because at some point of time this type of accident is going to happen.