Rendering and compositing shadows only with Cycles
Select the object you want to use for shadow data, go to the Object Settings tab, scroll down and enable the Shadow Catcher. Then, if you want it to overlay it on another scene, make a second Render Layer and select the scenes you want to use by pressing shift+LMB. Go to compositing and add an Alpha Over node and two RenderLayer nodes. Plug the first layer's Alpha channel into the Alpha channel of the Alpha Over node, plug its color into the bottom socket and the second layer's color into the top color socket.