Hello,
I found an easier way to make the object cast only shadows. It is an option on Cycles Settings of the Object Properties: it is the Shadow Catcher option. This option tells Blender to only render the shadows being casted on the object, “for compositing renders into real footage”.
Hope it helps.
P.S.: I don’t know if it works with Blender 2.77.