The purpose of the present study is to characterize electron contamination in photon beams in different clinical situations. Variations with field size, beam modifier (tray, shaping block) and source-surface distance (SSD) were studied. Percentage depth dose measurements with and without a purging magnet and replacing the air by helium were performed to identify the two electron sources that are clearly differentiated: air and treatment head. Previous analytical methods were used to fit the measured data, exploring the validity of these models. Electrons generated in the treatment head are more energetic and more important for larger field sizes, shorter SSD, and greater depths. This difference is much more noticeable for the 18 MV beam than for the 6 MV beam. If a tray is used as beam modifier, electron contamination increases, but the energy of these electrons is similar to that of electrons coming from the treatment head. Electron contamination could be fitted to a modified exponential curve. For machine modeling in a treatment planning system, setting SSD at 90 cm for input data could reduce errors for most isocentric treatments, because they will be delivered for SSD ranging from 80 to 100 cm. For very small field sizes, air-generated electrons must be considered independently, because of their different energetic spectrum and dosimetric influence.