The trapping of excitons in a semiconductor quantum well due to a circular symmetric nonhomogeneous magnetic field is studied. The effect of the spin state of the exciton on its trapping energy is analyzed, and the importance of the interaction of the orbital and spin Zeeman effect as compared to the diamagnetic term in the exciton Hamiltonian is emphasized. Magnetic field profiles are considered, which can experimentally be created through the deposition of ferromagnetic disks on top of a semiconductor heterostructure. This setup gives rise to a magnetic dipole type of profile in the xy plane of the exciton motion. We find that the spin direction of the exciton influences its localization by changing the confinement region in the effective potential. The exciton confinement increases with magnetic field intensity, and this is more pronounced when the exciton g-factor is different from zero. The numerical calculations are performed for GaAs/AlxGa1−xAs quantum wells and we show that it open up a new realistic path for experiments designed to probe exciton trapping in semiconductors. 71.35.Ji, 75.70.Cn, 71.70.Ej