A magnetometer is a device that measures magnetic field or magnetic dipole moment. Some magnetometers measure the direction, strength, or relative change of a magnetic field at a particular location. Other magnetometers measure the magnetic dipole moment of a magnetic material such as a ferromagnet, for example by recording the effect of this magnetic dipole on the induced current in a coil.
Smartphones come equipped with a magnetometer so that your phone can sense its orientation in space, and use basic apps like the Compass App to determine your location with respect to Magnetic North (or South). The way this is done is through an internal chip that contains a 3-axis X, Y, Z magnetometer.