Complex networks have been used intensively to investigate the flow and dynamics of many natural systems including the climate system. Here, we develop a percolation based measure, the order parameter, to study and quantify climate networks. We find that abrupt transitions of the order parameter usually occur ~1 year before El Ni~no events, suggesting that they can be used as early warning precursors of El Ni~no. Using this method, we analyze several reanalysis datasets and show the potential for good forecasting of El Ni~no. The percolation based order parameter exhibits discontinuous features, indicating a possible relation to the first order phase transition mechanism.