They don't say at what point you have to infiltrate, but if you force additional units to retreat into the city before opening the gates, it only makes sense that you check the % chance after those units retreat in. You are opening the gates to attack those units as well.