Photoelectrons are an extensively studied component of planetary ionospheres which have been frequently used as a diagnostic of ambient magnetic fields. We show in this study that they also provide information on atmospheric composition via the altitude variation of photoelectron intensity at specific energies. Such an idea is applied to Mars for which a large observational sample of photoelectrons is available from the Solar Wind Electron Analyzer measurements made by the Mars Atmosphere and Volatile Evolution (MAVEN). Our analysis reveals a strong decline in photoelectron intensity from 160 to 200 km, but this trend is restricted to a narrow energy range of 10-15 eV. By employing analytical yield spectrum calculations, we derive the model variations based on different choices of the background atmosphere. We find that the presence of CO is crucial for reproducing the observed variations. This allows atmospheric CO densities to be estimated from photoelectron measurements, which are a factor of 3-7 lower than the published densities based on the MAVEN Neutral Gas and Ion Mass Spectrometer measurements and in better agreement with existing model results. In general, the usefulness of photoelectron intensity at a specific energy as a tracer of atmospheric composition relies critically on the species-dependent inelastic electron impact cross section at this energy.