They have a "panel" people with electronic devices on their T.V's See here
http://www.barb.co.uk/about/tv-measurement
Viewing estimates are obtained from a panel of television owning private homes representing the viewing behaviour of the 26 million TV households within the UK. The panel is selected to be representative of each ITV and BBC region, with pre-determined sample sizes. Each home represents, on average, about 5,000 of the UK population.
You wonder how "representative" the panel is or unfortunately it could be that we are a nation of dimwitted proles judging by the inane crap that is shown as the most popular programmes