If your dog takes on a habit of pottying while you are away then you should know he or she is letting you know they are unhappy with you especially if they normally won't when you are home. Now if your pet has done it since they were young then its just a bad habit. If it started recently and maybe your schedule has changed then maybe this is the anxiety trigger causing your pet to do it's business on your carpet or floor.
Now these conditions of pet anxiety are only an Anxiety when they are left alone or seeking attention you won't give them." Or if they lost another pet or toy that had been in the household and now is gone". Kennel Training The more Time you spend with your pet The more likely they will suffer from a separation anxiety when you leave.
It is especially true if you let your pet sleep with you at night. One of the best ways to train your pet is to give it it's own place to sleep where it finds compfort. Train your puppy or dog by having them sleep in a kennel of appropriate size or a very small bathroom if you cant afford to by a kennel. Make sure the kennel is big enough to sleep in but not to big to allow them to poop and sleep in the kennel compfortable. Your pet will hold it in and it is a good way to make sure not only do they not poop in your home they will not be able to chew anything up either. Be sure to give them a toy or stuffed animal to entertain them while you are gone. Personally it does seem cruel to keep a dog in a kennel but you have to choose what is best for you and your pet not just what is best for your pet.