ABSTRACT This work focuses on the analysis of the mean longitudinal magnetic field as a stellar activity tracer in the context of small exoplanet detection and characterization in radial-velocity (RV) surveys. We use Solar Dynamics Observatory/Helioseismic and Magnetic Imager filtergrams to derive Sun-as-a-star magnetic field measurements, and show that the mean longitudinal magnetic field is an excellent rotational period detector and a useful tracer of the solar magnetic cycle. To put these results into context, we compare the mean longitudinal magnetic field to three common activity proxies derived from HARPS-N Sun-as-a-star data: the full width at half-maximum, the bisector span, and the S-index. The mean longitudinal magnetic field does not correlate with the RVs and therefore cannot be used as a one-to-one proxy. However, with high cadence and a long baseline, the mean longitudinal magnetic field outperforms all other considered proxies as a solar rotational period detector, and can be used to inform our understanding of the physical processes happening on the surface of the Sun. We also test the mean longitudinal magnetic field as a ‘stellar proxy’ on a reduced solar data set to simulate stellar-like observational sampling. With a Gaussian Process regression analysis, we confirm that the solar mean longitudinal magnetic field is the most effective of the considered indicators, and is the most efficient rotational period indicator over different levels of stellar activity. This work highlights the need for polarimetric time series observations of stars.