This is quite easy, but you need to do yourself a favor and get a factory wiring diagram. It will save you hours of frustration and confusion. The factory wiring diagrams will tell you exactly when the circuits are active and when they aren't. On top of that they will tell you the colors and sometimes the current flow.
You really don't want to hook up a tail light to a fan circuit (Personal experience) =P
Once you have that, you'll need some thin wire probes or insulation piercing probes. They come with the Power Probe 3, and fluke also sells them. A decent multi-meter should help you track down the wires you want to use. If you decide that you want to use your own method to pierce the wires, just remember to wrap them in high temp electrical tape. When insulation gets compromised the entire wire inside it can corrode. It's a real pain to try and figure that out.
If you want to try to sort this out the oldschool way you can use the multi-meter, probes, and a test light. Essentially what you would do is attach your test light or multi-meter to to ground, activate the circuit and test each wire individually. BUT I don't recommend doing this. As I said before, if you put a lock mechanism on a fan circuit that might intermittently kick on, you'll have some serious issues. You could possibly even put it on an EVAP circuit, which would probably mess with the EVAP without realizing it and every time you put gas in your car, your tailgate would drop. I would get wiring diagrams, there are so many wires in a vehicles it's really hard to do it the oldschool way.
That website carries a lot of factory wiring diagrams.
I hope I answered your question!