Counter-battery radar that can track artillery shells or ballistic rockets back to their point of origin have been around for many years now; the Israelis surely know exactly where the rockets are being fired from. I think they (usually) avoid firing back because they know there would be civilian casualties and want to avoid some of that bad PR.
One such system operated by Israel: https://en.wikipedia.org/wiki/EL/M-2084