Here's how it worked; I know this stuff pretty well.
The spacecraft had an "S-band transponder", basically a special kind of radio transceiver (transmitter and receiver). What made it special was a linkage between the receiver frequency and the transmitter frequency. When the receiver didn't detect a signal, the transmitter used a local oscillator to transmit on its nominal frequency; this could drift due to manufacturing tolerances, temperature, etc.
But when the receiver did receive an uplink signal from earth, it "phase locked" onto it and produced a transmitted frequency that was exactly 240/221 times the received signal frequency. This became the carrier of the downlink signal, which was designed so that the carrier was always present even with modulation (this isn't always true with some modulation methods).
The ground used a highly stable oscillator (an "atomic clock") to generate its uplink, and by producing a local reference signal 240/221 times its own transmit frequency, could compare that with the incoming downlink signal from the spacecraft. If the spacecraft were at constant distance from the ground, the two signals would be exactly the same frequency and phase. But if the spacecraft moves toward or away, the phase will rotate at some rate. Phase rate is the same as frequency, so there's a Doppler frequency shift.
The phase will rotate 360 degrees for every change in round trip distance of one wavelength, which at S-band is about 13 cm. The round trip distance changed one wavelength for every half wavelength of actual ground-spacecraft distance. And phase changes considerably less than 360 degrees could easily be detected.
So you can see how incredibly precise this method was; it could easily detect the changes in velocity caused by a simple urine dump (which led to an unfortunate misunderstanding during Apollo 13).
Doppler tracking was continuous, and if you knew at time t how far it was, by counting RF cycles you could keep track of its current distance. But how did you find the actual distance to start? With a separate mechanism called PN ranging. The ground could optionally transmit a fast (a little less than 1 Mb/s) pseudorandom data sequence to the spacecraft, which (if enabled by the crew) would repeat that signal on the downlink. The sequence was long enough to not repeat during the several seconds it could take the signal to reach Apollo and return, so the ground could compare it with its transmitted sequence and see to within 300 m (actually much less) what the round trip distance was and remember this figure for updating with Doppler. Then it could turn off the PN ranging signal.
PN ranging is widely used today; it's the basis of GPS, for example, and the Qualcomm CDMA digital cellular system that I worked on. GPS and CDMA all use different PN sequences from Apollo, but the "chip" (random bit) rates are remarkably close: 996 kHz (I think) for Apollo, 1.023 MHz for GPS, and 1.2288 MHz for CDMA. It made E911 position determination relatively straightforward, and if a CDMA phone was involved that's how the police found the Tsarnaev brothers in Watertown last month...
That you can continuously update a one-shot PN ranging measurement with Doppler is one of my disagreements with Hunchbacked. He insists the PN signal has to be on all the time, and the fact that it can be turned off is one of his many discovered "incoherences". I've tried to explain how the Doppler tracking is coherent and continuous so the PN ranging only need be done at first acquisition and after any loss of signal, but to no avail...