Impurities in ZnO specimens, including targets for pulsed laser deposition and thin films resulting from their use, were analyzed by secondary ion mass spectroscopy (SIMS). Negatively charged complex ions bound with oxygen ((GaO-)-Ga-71-O-16 and (NO-)-N-14-O-16) were found to be the most reliable species with which to evaluate the Ga and N content of ZnO films by clarifying possible mass interference effects in SIMS analysis. Calibrations were carried out to determine the Ga concentration (C-Ga) and the nitrogen concentration (C-N) by normalizing the signal intensities for (GaO-)-Ga-71-O-16 and (NO-)-N-14-O-16, respectively, to that for (ZnO-)-Zn-70-O-16. Alternative ablation of pure single crystal and Ga-doped ceramic ZnO targets was found to be effective not only for achieving systematic control of the Ga concentration in ZnO:(Ga,N) films, but also for minimizing the contamination of undesired impurities from the sintered targets. The substrate temperature plays a decisive role in control of C-N due to a thermally activated desorption process of N-related species during deposition. Systematic control of the C-N/C-Ga ratio in a ZnO:(Ga,N) film was carried out on a ScAlMgO4 substrate by introducing a controlled temperature gradient on the substrate during deposition. A region with the correct concentration ratio of C-N/C-Ga=2, where p-type conduction of the ZnO film was theoretically predicted, was included in the composition spread sample in which the C-N/C-Ga ratio was continuously varied over a wide range.