If you want to clean all carpeting first remove all old and stubborn stains. Vacuum the carpet several times and then rub with a concentrated solution of water and dishwashing detergent or shampoo.
Add vinegar or lemon juice in that solution. The ideal formula: one part bleach, two parts water and one lemon juice or some vinegar.
Use a sponge soaked in cleaning solution and rub the carpet in a circular motion. Clean the foam formed immediately with clean towels. Well ventilate the room and leave the windows open at least 12 hours after this operation. Vacuum again at the end to remove all particles from the carpet surface.