In this paper, we propose a novel framework that aims to jointly design the reflection coefficients of multiple reconfigurable intelligent surfaces (RISs) and the precoding strategy of a single base station (BS) to optimize the selftracking of the position and the velocity of a single multi-antenna user equipment (UE) that moves either in the far-or nearfield region. Differently from the literature, and to keep the overall complexity affordable, we assume that RIS optimization is performed less frequently than localization and precoding adaptation. The proposed procedure leads to minimize the inverse of the received power in the UE position uncertainty area between two subsequent optimization steps.The optimal RIS and precoder strategy is compared with the classic beam focusing strategy and with a scheme that maximizes the communication rate. It is shown that if the RISs are optimized for communications, their configuration is suboptimal when used for tracking purposes. Numerical results show that in typical indoor environments with only one BS and a few RISs operating on millimeter waves, high location accuracy in the range of less than half a meter can be achieved.Index terms-Reconfigurable Intelligent Surfaces, Bayesian tracking, MIMO, Optimization.