Replacing a derailleur hanger is not a complex operation, but it must be done correctly to get the perfect shifting you expect from your derailleur.
In addition, in many cases, a broken derailleur hanger is a sign of a problem in the transmission: rear derailleur bent or improperly adjusted, chain damaged or too short ... If you don't check and do not solve the problems, new hanger could break quickly.
Don't hesitate to entrust your bike to a professional mechanic. Otherwise be sure to follow the tips below.
Then check the inboard and outboard limit adjustment and the index adjustment.
New hanger can be different in thickness of origin, also make sure to adjust the quick release wheel so that it is tight enough.
Derailleur replacement hanger is now complete and you've probably got "the Perfect Shifting".