The conducting interface of LaAlO$_3$/SrTiO$_3$ heterostructures has been studied by hard X-ray photoelectron spectroscopy. From the Ti~2$p$ signal and its angle-dependence we derive that the thickness of the electron gas is much smaller than the probing depth of 4 nm and that the carrier densities vary with increasing number of LaAlO$_3$ overlayers. Our results point to an electronic reconstruction in the LaAlO$_3$ overlayer as the driving mechanism for the conducting interface and corroborate the recent interpretation of the superconducting ground state as being of the Berezinskii-Kosterlitz-Thouless type.