Set the combination on the lock if it is a combination-lock variety.
Keep the lock held onto the bag using one or more small plastic cable ties. How you do this will depend on the type of bag you have. Try laying one cable tie flat across the body of the lock and laying another flat across the first at right angles to it. Pull the second cable tie tight around the lock, while holding the first tie in place. Loop the first tie into a buckle near the bag's opening or around the drawstring's fastener to keep it from falling off the bag.
Pull the lock's retractable cable out from the lock until you have about 2 inches free.
Feel where the drawstring runs around the opening of the bag. The lock cable needs to follow the drawstring through the sleeve or the rings that the drawstring goes through. Feed the lock's cable into the sleeve or rings where the drawstring enters and keep pushing it around until it has gone all the way around the opening of the bag beside the drawstring.
Take hold of the loose end of the cable as it comes out of the drawstring sleeve and lock it into the lock. Retract the slack until the top of the bag is tightly secure.