Context. Stellar activity poses one of the main obstacles for the detection and characterisation of small exoplanets around cool stars, as it can induce radial velocity (RV) signals that can hide or mimic the presence of planetary companions. Several indicators of stellar activity are routinely used to identify activity-related signals in RVs, but not all indicators trace exactly the same activity effects, nor are any of them always effective in all stars. Aims. We evaluate the performance of a set of spectroscopic activity indicators for M dwarf stars with different masses and activity levels with the aim of finding a relation between the indicators and stellar properties. Methods. In a sample of 98 M dwarfs observed with CARMENES, we analyse the temporal behaviour of RVs and nine spectroscopic activity indicators: cross-correlation function (CCF) full-width-at-half-maximum (FWHM), CCF contrast, CCF bisector inverse slope (BIS), RV chromatic index (CRX), differential line width (dLW), and indices of the chromospheric lines Hα and calcium infrared triplet. Results. A total of 56 stars of the initial sample show periodic signals related to activity in at least one of these ten parameters. RV is the parameter for which most of the targets show an activity-related signal. CRX and BIS are effective activity tracers for the most active stars in the sample, especially stars with a relatively high mass, while for less active stars, chromospheric lines perform best. FWHM and dLW show a similar behaviour in all mass and activity regimes, with the highest number of activity detections in the low-mass, high-activity regime. Most of the targets for which we cannot identify any activity-related signals are stars at the low-mass end of the sample (i.e. with the latest spectral types). These low-mass stars also show the lowest RV scatter, which indicates that ultracool M dwarfs could be better candidates for planet searches than earlier types, which show larger RV jitter. Conclusions. Our results show that the spectroscopic activity indicators analysed behave differently, depending on the mass and activity level of the target star. This underlines the importance of considering different indicators of stellar activity when studying the variability of RV measurements. Therefore, when assessing the origin of an RV signal, it is critical to take into account a large set of indicators, or at least the most effective ones considering the characteristics of the star, as failing to do so may lead to false planet claims.