Apple tracks when you are close to an Apple Store
linkedin.com
linkedin.com
Additionally, I bet they're using some iBeacons to track when you enter the store. These work over Bluetooth LE and the phone can do different things when it hits a nearby beacon.