It takes practice, and having a general idea what size a monster's hitbox is.
DEFINITELY make sure you don't have Frostbite, a single mob getting out of the pack will fuck your entire wagon, and fast.
It's still doable with frostbite, but it's a LOT trickier. If possible, it's best to avoid frostbite all together. But not entirely impossible if you have it.