Happened to me before. It's been the rear door jamb both times. I'd start by replacing the rear door jamb first if you can't figure out which one it is.
Takes maybe 1 minute to swap in a new one and they are fairly cheap.
https://www.amazon.com/gp/product/B0016HPWCM
I've got a funky sensor somewhere as my radio keeps staying on if the drivers door is opened - works great for any other door. Is this the same sensor front / rear?