The BEST way to get chewing gum out of carpet is to hire a professional who knows the right amount of solvent to use and is able to immediately extract that solvent as to not delaminate your carpet.

If you still want to try it on your own, you can purchase a product called Goof Off from one of the big box stores. But really any citrus-based solvent will do. Go slow and don’t apply too much. Work on it gently with a plastic utensil or similar tool that’s not too abrasive. Stop if you see the fibers separating from the backing. If possible, flush the solvent out asap with a water extraction device.