A detection system for detecting the presence and direction of a subject moving through a doorway is disclosed. The system comprises magnets disposed on the doorway, a communication device, typically a smartphone and a server. The magnets are positioned on the doorway to create a magnetic field across the doorway. When the subject having the smartphone on the body passes through the doorway, a magnetometer in the smartphone senses perturbations caused by the magnetic field and generates signals corresponding to the sensed perturbations and a processor of the smartphone processes the signals to detect the presence and direction of the subject through the doorway. The data generated by the processor and a unique identification associated with the smartphone is transmitted to the remotely located server.