When crossing the percolation threshold the optical behavior of thin metal films dramatically change within a narrow range. Recording the optical properties in the vicinity of the percolation provides insight into the interplay of those contributions that determine the intensity of the second harmonic signal: the metallic islands and the dielectric gap between the islands. Here we demonstrate the active tuning of the linear and nonlinear optical properties of a thin gold film on a stretchable PDMS substrate. Ellipsometry was combined with nonlinear studies (second-harmonic generation) to describe the optical properties of thin gold films around the percolation. We monitor the metal-insulator transition, characterize the evolution of the permittivity of the layer, and explain the strength variations of the second harmonic generation with respect to the spectral difference between fundamental wavelength and plasmonic resonance, as well as the enhancement of the field in the dielectric gaps as a function of the particle-particle distance. A model reproduces the experimental observations by taking into account both effects at the fundamental and at the generated wavelengths.