You need a biological agent to get rid of the smell, no cleaners really work that well. Something like this works really well.
https://urineoff.com/ Once you apply this properly, it will kill the smell, then use a cleaner after is the best results.
If you want to keep your house clean and help prevent this sort of thing, don't let your dog in these areas with expensive carpets if he/she is going to be, maybe invest in some puppy pads and put them in those rooms, on those spots he/she likes to pee. Once they learn this is good (the new spot, praise her/him and give treats, get excited), you can leave the pads near say the back door or front door, once they get the idea you give them a lot of praise, pets, treats etc.
We fostered a little chihuahua and had similar issues. She would always kind of try to hide from us, but would tend to find rugs instead (we have tile and hardwood everywhere else she was allowed to go) and do her business there, we started using puppy pads and praising her when ever she would go on them, and say outside when she was going. After about 2 weeks, she learned that she had to wait and go outside. My sister's 14 year old dog has always had spotting issues and they just took out all the carpets in the house, that is another way to deal with it if you are going to have pets (this seems extreme!).
Anyway, you need a natural agent to get rid of the smell (for the dogs, as they smell way better than we do), then something to deep clean and lift that stains off and smells clean again.