A factory reset generally erases all data and software installed on the device, which usually includes tracking software. However, it won't remove tracking at the carrier level or if your phone has been compromised at a deeper, firmware level.