I would first see the vet to rule out a medical reason for the behavior. Sometimes when they feel bad, this is their way of letting us know.
I'm sure that all specialists might disagree on this one but all that I can tell you is what I know from my own experiences.
Some dogs are often quite hard to train so you need to go back to the basics.
You need to get a crate and use it. Dogs are very reluctant to use the bathroom where they sleep so she will quickly learn to hold it. Put her in the crate when you are not home and sometimes when you are.
Get a deodorizer and get her scent out of the carpet. You can buy odoban at the grocery store and it works great. And it's not terribly expensive.
After she has been in the crate for a while, take her straight outside and watch her. Be sure you have a pocket full of treats and when you catch her going potty outside, give her one. Take her inside. If this doesn't help, you may have to repeat this and put her right back in the crate. Then take her out, catch her being good and then put her back in it when you go inside. She will soon learn that outside is the place for potty.
As you learn to trust her, you can widen her area and leave her free in the house when you go to the store or to take a nap. If she disappoints you, take away the priviledge.
Be sure that you don't shame her when you catch her going inside. Just take her out and start over.
Let me know if you have more questions.