We propose a strategy for detecting and analyzing optical afterglows (OAs) of long gamma-ray bursts (GRBs) without the need to obtain their light curves. This approach is useful for the Gaia satellite, which provides sampled optical ultra-low-dispersion spectroscopic observations of the sky. For this purpose, we show that most OAs of long GRBs display specific values of some of their color indices, representing synchrotron emission of the jet. They are stable in time during the event. These indices, which can be determined from the spectra, are very similar for the ensemble of OAs with redshift z < 3.5 and display a strong clustering in some color-color diagrams. These indices also enable to constrain the properties of the local interstellar medium of GRBs. The long-lasting mapping of the sky with the Gaia instruments also gives us a hope to search for the so-called orphan afterglows, which, according to some authors, can be considerably more numerous than OAs of the observed GRBs. We also show how to resolve OAs from other transients in the Gaia data. The color indices and the properties of the quiescent sources (host galaxies of OAs detectable later by the large ground-based telescopes at the co-ordinates of the OA determined by Gaia) would tell us which one, among transients detected by Gaia, is a GRB OA.