Turn off the water to the tub faucet by closing the valves in the wall (accessed through a panel behind the wall on which the faucet is mounted) or by turning off the home’s water main near the water meter.
Pull the cap off the top of the faucet handle and unscrew the Allen-head screw under it. If your faucet doesn’t have a cap, it will have a set screw on the side of the handle. Find the screw and remove it with an Allen wrench.
Take the handle off the faucet head and look for a small retainer clip around the edge of the cartridge underneath. Use a pair of pliers to remove this clip. If there is a bonnet cap or washer, loosen and remove this either by hand or with a pair of pliers.
Slide the cartridge out of the faucet head and install a new cartridge in place of the old one. Press it to the back of the faucet head and then fit the clip around it to secure it, or reinstall the washer to hold it in place.
Put the handle back on the stem of the cartridge and fasten it with the set screw to hold it in place. Turn on the water and test the faucet.