In many important situations, the dominant dephasing mechanism in cryogenic rare-earth-metal-ion--doped systems is due to magnetic field fluctuations from spins in the host crystal. Operating at a magnetic field where a transition has a zero first-order Zeeman (ZEFOZ) shift can greatly reduce this dephasing. Here we identify the location of transitions with a zero first-order Zeeman shift for optical transitions in Pr
3+:YAG and for spin transitions in Er
3+:Y
2SiO
5. The long coherence times that ZEFOZ can enable would make Pr
3+:YAG a strong candidate for achieving the strong-coupling regime of cavity QED, and would be an important step forward in creating long-lived telecommunications wavelength quantum memories in Er
3+:Y
2SiO
5. This work relies mostly on published spin-Hamiltonian parameters, but Raman heterodyne spectroscopy was performed on Pr
3+:YAG to measure the parameters for the excited state.