This issue is generally due to an alignment issue between the transmitter and magnet, or that there is play in the door or window.
Verify that the arrows on the two pieces are aligned properly with the arrows directly across from each other
Ensure the two pieces are no further than a thumb's width apart from one another (3/4")
Check for a recession in the door/window frame. Both pieces should be on the same plane with each other
Be sure there is no play (movement) in the door or window when it is closed