I’ve always had good luck with white vinegar (best when spot is fresh) followed by baking soda when carpet is dry. Woolite has a commercial pet cleaner but the product’s sweet smell is almost as bad as what you are trying to clean-up. Can also try the local natural pet shops.
I second Nature’s Miracle – used to use that with an incontinent cat. Just be aware that with enzyme odor removers 1) the smell doesn’t go away instantly, it can take a week or two to dissipate and 2) you need to fully saturate the affected area of the carpet – no skimping.