Sure, there is a little trap in the question: in statistical terms, in Spain a tourist is a person that moves from his usual home to a different geographical point, is far from home more than 24 hours, and sleeps in a different geographical place. So, a one day trip to go eat some ribs and then coming back home for your siesta is not, technically speaking, tourism (even if some professionals sometimes count it as such).
But visiting your grandmother in her small village in the Yorkshire Moors for some days could be counted as tourism (even if you spend not a penny out of her home).
I remember a speech by a former Barcelona City Councilor, now high executive for a tourism company, in which he explained how they were baffled, in the early 1990s, to see the streets of the city bustling with Japanese tourist, while there were virtually no Japanese staying in city hotels. It seems the City Council played a detective game by following around the clock some groups of Japanese tourists, to finally discover that they were sleeping in southern France (therefore concentrating there most of their tourism expenditure) and commuting each day by bus from there. Since, Barcelona has made everything to foster Asian tourism, to become the Spanish airport with most flights to Asia.
So, as for many other issues, knowing the precise number of tourists, and their expenditure profile, is always complex and there will always be a degree of fuzziness (it is incredible how many grandmas, or friends letting you use their apartment, exist in this world…), but there are attempts. A method is to count, for a given period, the number of beds open to the public in hotels and other kinds of lodging, and to multiply it by the occupation rate. This does not include the “unregulated offer” (grandmas, friends, or house renting by ordinary citizens), but it is an attempt. The tourism expenditure (which has its own statistical niceties) is a more important affair sometimes.