how do I add a shadow on the floor of a tracking scene?
You must search for: Shadow catcher.
The blender will improve it in future versions but today we have to use two objects as you did, render the object, the ground without the shadow and the ground with shadows then use the node editor to join all.
The main object in the Layer 1, the ground in the second Layer.
See it bellow...(names in Portugese, my main language)