You will go through immigration in Miami, then pick up your bags and go through customs. As you leave customs there will be somewhere to hand your bags back rather than go around to the bag dropin departures. You then make your way to your next gate.