SrTiO$_3$ is an incipient ferroelectric on the verge of a polar instability,
which is avoided at low temperatures by quantum fluctuations. Within this
unusual quantum paraelectric phase, superconductivity persists despite
extremely dilute carrier densities. Ferroelectric fluctuations have been
suspected to play a role in the origin of superconductivity by contributing to
electron pairing. To investigate this possibility, we used optical second
harmonic generation to measure the doping and temperature dependence of the
ferroelectric order parameter in compressively strained SrTiO$_3$ thin films.
At low temperatures, we uncover a spontaneous out-of-plane ferroelectric
polarization with an onset that correlates perfectly with normal-state
electrical resistivity anomalies. These anomalies have previously been
associated with an enhancement of the superconducting critical temperature in
doped SrTiO$_3$ films, directly linking the ferroelectric and superconducting
phases. We develop a long-range mean-field Ising model of the ferroelectric
phase transition to interpret the data and extract the relevant energy scales
in the system. Our results support a long-suspected connection between
ferroelectricity and superconductivity in SrTiO$_3$, but call into question the
role played by ferroelectric fluctuations.