Context. Radial velocities (RVs) of stars contain both the Doppler reflex motion of potential planetary companions and the drowning and sometimes imitating effect of stellar activity. To separate the two, previous efforts have sought proxies that only trace the activity signals, yet the sub-meter-per-second floor required for the detection of Earth-like planets remains difficult to break. Aims. In this work, we analyze a sample of 12 G- to early M-type stars in order to investigate the feasibility of detecting a differential effect of stellar activity with photospheric depth, as traced by the spectral line-forming temperature, for observations with different sampling and noise levels. Methods. We computed the average line formation temperature for each point in the observed wavelength grids using the spectral synthesis code PySME. The final line selection was curated to exclude blended and poorly synthesized lines. We thereafter computed the convective blueshift (CB) of the line cores of our master spectra (composed of the stacked individual spectra of each star). Finally, we extracted RV time series for certain intervals of formation temperature using a template-matching approach. Results. We find the CB to follow a linear relation with the formation temperature of the line cores, and the CB slope to be steeper with increasing effective temperature. For the RV time series derived for different intervals of formation temperature, we find the RVs of line parts formed at higher temperatures, close to the spectral continuum, to be generally correlated with the S index, and the RVs of line parts formed at cooler temperatures, close to the spectral line cores, to be generally anti-correlated, especially for stars with low noise levels and significant variations over their magnetic cycles. Conclusions. RVs of line parts formed in the coolest 25% of the line-forming temperature range appear to be a strong tracer of stellar activity over the magnetic cycle for several stars. By detrending the total RV time series with a multi-linear combination of residuals of RVs measured at different temperature ranges and the S index, the RV scatter can be decreased to a greater extent than with the S index alone.