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. 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. 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), contrast, and bisector inverse slope (BIS), chromatic index (CRX), differential line width (dLW), and indices of the chromospheric lines H$alpha$ and calcium infrared triplet. 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. 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.