If you are collecting samples for bacterial studies, you need to have samples directly from the intestinal compartments. You could collect samples from the cage, but you need to control for the cage environment bacteria. If you are collecting samples for things other than bacterial studies, you may go ahead and collect samples from cages.
Use autoclaved microisolator cages that allow mouse/rat to defecate normally and collect the first two fecal pellets per animal into an empty 1.5 mL Eppendorf tube using a sterile toothpick. Close tube securely and preserved it to -80°C freezer immediately