The root of Salvia miltiorrhiza Bunge (SMB) has been widely used to treat cardiovascular diseases. However, the contents of secondary metabolites in the roots from different production areas are significantly different, and the impact of soil factors on this accumulation remains unclear. Therefore, this study aimed to elucidate the regularity of variation between the active components and soil factors through targeted metabolomics and chemical dosimetry. Soils were collected from five different cities (A, B, C, D, and E) and transplanted into the study area. The results showed that there were significant differences in the soil fertility characteristics and heavy metal pollution levels in different soils. Ten water- and twelve lipid-soluble metabolites were identified in SMBs grown in all soil types. SMBs from D cities exhibited the highest total tanshinone content (p < 0.05). The salvianolic acid B content in SMBs from E cities was the highest (p < 0.05). Interestingly, correlation analysis revealed a significant negative correlation between the accumulation of lipid-soluble and water-soluble metabolites. Double-matrix correlation analysis demonstrated that available potassium (AK) was significantly negatively correlated with salvianolic acid B (r = −0.80, p = 0.0004) and positively correlated with tanshinone IIA (r = 0.66, p = 0.008). Conversely, cadmium (Cd) and cuprum (Cu) were significantly positively and negatively correlated with salvianolic acid B (r = 0.96, p < 0.0001 and r = 0.72, p = 0.0024) and tanshinone IIA (r = 0.40, p = 0.14 and r = 0.73, p = 0.0018), respectively. Mantel’s test indicated that AK (r > 0.52, p < 0.001), Cu (r > 0.60, p < 0.005), and Cd (r > 0.31, p < 0.05) were the primary drivers of the differences in the active components of SMBs. These findings provide a theoretical framework for modulating targeted metabolites of SMB through soil factors, with significant implications for the cultivation and quality control of medicinal plants.