The back door in a Jeep Grand Cherokee (1998) is always reading open, even when it's closed quite firmly. This causes the vehicle to beep when the car is being driven. I've taken apart the door, played with the sensor until it reads closed again, put everything back together, and give it a final test, to which it stops working again. Do I need to replace the sensor, or just learn to fix the sensor better?
The sensor itself is only part of the equation. There is also:
If the sensor works consistently when you manually press it, then it tells me that it's not getting reliably pressed by the door when the door is closed. This could be because the striker or door is out of adjustment or because the sensor itself doesn't sit properly in its hole. If the door has been involved in an accident at some point, this is an area to examine very closely.
If the sensor is intermittent even when manually pressing it, then test the sensor with an ohmmeter.
I had the same problem on my '98 GC and it turned out to be lock/sensor on the glass hatch door. By pulling the cover off the entire hatch, I could tweak the wires going into the sensor/lock assemblies. When I torqued the one on the glass door, it would go on and off.
While I haven't found a good way to fix it yet, I was able to yank the wires off that assembly completely and the problem went away until I do (remember to lock it first, if you care). I lose the ability to use that glass door, but it hasn't bothered me enough to fix it yet.