An innovative setup to combine electrochemical and in situ surface X-ray diffraction (SXRD) measurements is described. This electrochemical cell has a different design from the other ones commonly used for X-ray diffraction studies. It allows the sample surface to stay always completely immersed into the solution under controlled potential conditions even during the SXRD measurements. The X-ray beam crosses the liquid (about 1cm) and the cell walls. Because of the high X-ray energy, the beam attenuation is negligible and by an appropriate positioning of the detector arm slits it is possible to minimize the diffuse scattering induced by the liquid and cell walls in order to still detect the minima of the crystal truncation rods (CTRs). The liquid solution in the cell is managed by a special device, which allows the controlled exchange of the electrolyte solutions necessary in the electrochemical atomic layer epitaxy (ECALE) growth. The whole setup can be remotely controlled from outside the experimental hutch by a dedicated computer. As an example we report measurements on S layers deposited at underpotential on the Ag(111) surface, and on CdS films of increasing thickness.