I don’t know the specific methods in all cases, but in the cases I’m aware of, primarily through direct questioning of those watching the rallies outside and exit polling of those inside.
In the case of the NJ rally, for example, the original numbers were 28% Democrats and 17% who didn’t vote in 2016. The corrected numbers were 26.3% and 10%, respectively. Applicants for tickets apply online and provide their emails, so I assume the corrected numbers are the result of polling after the fact.
Sounds reasonable, but still, 10’s of thousands? They are probably extrapolating from a small percentage like polls do.