This is usually done with WiFi MAC addresses. I know that London did this for tube journeys but I'm not sure anybody's done it for busses. You can also use smart card IDs if there is an RFID payment system.
The introduction of randomised MACs might have put an end to it.