Keep in mind that if you plan on replacing the carpet the patch will adhere to the padding making it harder to salvage the pad.
Carpet patch does not match carpet.
The biggest factor is whether or not a piece of carpet from a closet or remnant piece will match.
Unless you have an extra piece to spare somewhere else this is going to be your best bet.
Even if you were lucky enough to find the exact carpet the dye lots would not match.
Hold the patch in place for a little while.
Apply some carpet adhesive onto the patch requiring floor.
Take a portion of the carpet and start looking around your local home depot or other carpet place to find a close match.
Tools and supplies you will need.
Due to sun fade and wear the piece that is patched in may look newer then the original worn carpet.
It may not be an exact match but it will a game of horseshoes finding the closest thing possible.
Because the donor area is filled in either with a piece of remnant carpet or is left unrepaired carpet patching is considered to be imperfect but a net overall improvement.
If carpet tape is not doing the job you can also use carpet glue to hold the patch in position.
Never use more than three different.
The best way to have an idea of what the results will be would be to take a remnant piece and set it next to the area that needs to be patched.
A line or 2 of glue on the surface of the carpet pad will often be sufficient.
There is a rule of thumb for using a variety of flooring throughout a home.