I have done that myself several times, at least 30 windows and 10 doors. When the window comes from the manufacturer with sensors already integrated, there is a cable coming out of the frame on one side. This is routed into the empty conduit and extended there with a crimp connector. This works not only almost without problems, but always without problems.
That is clear, I have it the same way at my place. But that was not the question, because the windows are already pre-drilled at the factory there, and the cables can be properly inserted and sealed during window installation.
We ourselves have planned a wooden stud construction and are doing the drywall ourselves. Therefore, all walls are still empty (no insulation) and open during window installation. I am not worried at all about the connection.
OK, that is something different. If you get behind the window frame (more precisely, you don’t, you will have wood studs all around), then it is comparatively easy.
If you have no concerns about drilling precisely through the window frames & wooden beams yourself, then it is of course easily possible.
Just take an installation contact switch, e.g. BSS 404042.x, drill through the window frame (if necessary only drill the wood studs with a diameter for the cable) and the sash only as deep as the magnet is long and glue/screw (depending on the manufacturer) the parts on. Provided no locking monitoring is desired, this is also relatively easy to retrofit.