Allied intelligence was well aware of German V2 rocket research and production long before the first rockets were fired at London. This was largely facilitated by extensive communication networks with continental insurgents, spying, and very sophisticated cryptanalysis efforts. The Poles played a big part in all three respects. Believe it or not, in July 1944 Polish forces actually managed to steal a test rocket that had failed to explode upon landing, in a mission known as Operation Most III. It was taken apart and delivered to London shortly thereafter. So the first V2 to arrive in London was delivered in a box, two months before the actual V2 attacks began.
As you can imagine then, the Allies knew the rockets were coming eventually. The populace on the other hand, did not, and the British government actually attempted to prevent hysteria by blaming the explosions on exploding gas mains.
Follow up question: How did they managed to aim them? Primitive computers?
Besides the idea of demoralizing the British by bombardment, similar to the bombing of London during the battle of Britain, are there any real practical reasons why the weapons were not aimed at military targets such as ports/troop concentrations/supply dumps?
in other words, if used differently, would the V2s have had a chance of actually being useful in the war effort?