Context. Cosmic rays (CRs) heavily impact the chemistry and physics of cold and dense star-forming regions. However, the characterisation of their ionisation rate continues to pose a challenge from the observational point of view. Aims. In the past, a few analytical formulas have been proposed to infer the cosmic-ray ionisation rate, ζ2, from molecular line observations. These have been derived from the chemical kinetics of the involved species, but they have not yet been validated using synthetic data processed with a standard observative pipeline. In this work, we aim to bridge this gap. Methods. We performed a radiative transfer on a set of three-dimensional magneto-hydrodynamical simulations of prestellar cores, exploring different initial ζ2, evolutionary stages, types of radiative transfer (for instance assuming local-thermodynamic-equilibrium conditions), and telescope responses. We then computed the column densities of the involved tracers to determine ζ2, employing a recently proposed method based on the detection of H2D+. We compared this approach with a previous method, based on more common tracers. Both approaches are commonly used. Results. Our results confirm that the equation based on the detection of H2D+ accurately retrieves the actual ζ2 within a factor of two to three in the physical conditions explored in our tests. Since we have also explored a non-local thermodynamic equilibrium (non-LTE) radiative transfer, this work indirectly offers insights into the excitation temperatures of common transitions at moderate volume densities (n ≈ 105 cm−3). We also performed a few tests using a previous methodology that is independent of H2D+, which overestimates the actual ζ2 by at least two orders of magnitude. We considered a new derivation of this method, however, we found that it still leads to high over-estimations. Conclusions. The method based on H2D+ is further validated in this work and demonstrates a reliable method for estimating ζ2 in cold and dense gas. On the contrary, the former analytical equation, as already pointed out by its authors, has no global domain of application. Thus, we find that it ought to be employed with caution.