In the context of smart cities, there is a general benefit from monitoring close encounters among pedestrians. For instance, for the access control to office buildings, subway, commercial malls, etc., where a high amount of users may be present simultaneously, and keeping a strict record on each individual may be challenging. GPS tracking may not be available in many indoor cases; video surveillance may require expensive deployment (mainly due to the high-quality cameras and face recognition algorithms) and can be restrictive in case of low budget applications; RFID systems can be cumbersome and limited in the detection range. This information can later be used in many different scenarios. For instance, in case of earthquakes, fires, and accidents in general, the administration of the buildings can have a clear record of the people inside for victim searching activities. However, in the pandemic derived from the COVID-19 outbreak, a tracking that allows detecting of pedestrians in close range (a few meters) can be particularly useful to control the virus propagation. Hence, we propose a mobile clustering scheme where only a selected number of pedestrians (Cluster Heads) collect the information of the people around them (Cluster Members) in their trajectory inside the area of interest. Hence, a small number of transmissions are made to a control post, effectively limiting the collision probability and increasing the successful registration of people in close contact. Our proposal shows an increased success packet transmission probability and a reduced collision and idle slot probability, effectively improving the performance of the system compared to the case of direct transmissions from each node.