Found in high end UAV stabilization systems, magnetometers have their own set of pluses and minuses.
Magnetometers point to the magnetic north. This has nothing to do with what we think of as north or the so-called true north. In fact, the magnetic north is constantly changing in location and strength. It even changes strength depending on the time of day!
The government publishes tables that let you correct from magnetic north to true north. The tables need to be constantly republished because the magnetic north and the flux lines move around so much. You also need to know your exact location to use the tables, which is not available unless you also have a GPS sensor.
Running electric motors generate strong magnetic fields. Large chunks of ferrous metals also affect magnetic fields. This means that a gas engine, a steel wing joiner, or a metal landing gear can affect the readings. As a rule of thumb, keep an electric motor at least a foot away from the magnetometer.
The good news with magnetometers is that they are not subject to drift. The readings will be consistent throughout the flight. Also, you normally do not care if it is pointing to the magnetic north or the true north. You just need a consistent reference direction. Magnetometers work great for that. They are also reasonably reliable indoors, which cannot be said of GPS sensors.