We present a detailed statistical study of massive star formation in the environment of 322 Spitzer mid-infrared bubbles by using the Red MSX Source (RMS) survey for massive young stellar objects (YSOs). Using a combination of simple surface density plots and a more sophisticated angular cross-correlation function analysis, we show that there is a statistically significant overdensity of RMS YSOs towards the bubbles. There is a clear peak in the surface density and angular cross-correlation function of YSOs projected against the rim of the bubbles. By investigating the autocorrelation function of the RMS YSOs, we show that this is not due to intrinsic clustering of the RMS YSO sample. RMS YSOs and Spitzer bubbles are essentially uncorrelated with each other beyond a normalized angular distance of two bubble radii. The bubbles associated with RMS YSOs tend to be both smaller and thinner than those that are not associated with YSOs. We interpret this tendency to be due to an age effect, with YSOs being preferentially found around smaller and younger bubbles. We find no evidence to suggest that the YSOs associated with the bubbles are any more luminous than the rest of the RMS YSO population, which suggests that the triggering process does not produce a top-heavy luminosity function or initial mass function. We suggest that it is likely that the YSOs were triggered by the expansion of the bubbles and estimate that the fraction of massive stars in the Milky Way formed by this process could be between 14 and 30 per cent.