A better sparing of healthy tissue and critical organs surrounding a tumor volume is reached in ion beam radiotherapy, in comparison with the conventional X-ray radiotherapy. In radiotherapy with carbon ions, that requires the use of synchrotrons, however, the ion beam delivery is more prone to uncertainties due to the fine-tuning of the beam delivery system, compared to radiotherapy with cyclotron-based protons. These uncertainties can affect the lateral position of the beam during the treatment delivery. This work presents a methodology to monitor the lateral beam positions with high precision by exploiting the tracking of secondary ions produced inside the patient during the treatment delivery. For the secondary ion tracking, a mini-tracker based on Timepix3 detectors was used. The performance of the method was tested in realistic clinic-like treatment situation using an anthropomorphic head phantom irradiated with typical doses at the Heidelberg Ion-Beam Therapy center in Germany. By tracking the secondary ions, the total number of lateral pencil beam positions were successfully measured. Using these data, the beam scanning movement during the delivery was visualized in detail. By comparing to the reference, the majority of the precision and accuracy values were in line with the clinically accepted uncertainties of ±1 mm.