What did it get wet with? If it is something like flood water, you will never be able to get the smell out no matter what you do.
If it is something like urine,a urine remover for carpet does the job quite nicely( I have a cat who used to have accidents) I have my own carpet cleaner,and I just use the urine remover in it,and it works wonders.
If you just have a funky carpet,get it professionally cleaned.
If you like the way it turns out,ask them what you can do to maintain the results as long as you can.
The best hint I ever got was to get rid of smells in your carpet after it is cleaned and dry,is to shake ordinary baking soda onto your carpet,and kind of work it in with a clean broom,and let it sit for about a half an hour the just vacuum. If you don't like you house all scented up with all of those expensive,smelly powders that they have, baking soda works wonders. It does not harm your kids, animals, or your houseplants either.