For the analysis of oxygen and nitrogen in heavy matrices, (d, p) and (d, α) reactions with deuteron energies around 1 MeV are commonly employed because of their reasonable cross sections and favourable Q-values. Unfortunately, depth profiling of oxygen or nitrogen in the presence of other light elements by means of these reactions is often severely hampered due to overlapping particle groups. In the case of nitrogen, the analysis is furthermore complicated by interference between its own proton groups. However, by detecting a particular particle group in coincidence with its accompanying gamma ray transition, background particles can be suppressed by at least two orders of magnitude. By this method it is possible to determine depth profiles of oxygen or nitrogen in relatively pure samples at the ppm level or, with reduced sensitivity, in samples with severe background problems. The applicability of this technique is demonstrated in case of the reactions 16O(d, p 1) 17O and 14N(d, p 5) 15N for a number of oxygen- and nitrogen-containing samples. Various aspects of the experimental setup are discussed.