Thanks to the advent of the gamma-ray space observatories (in particular AGILE and Fermi satellites) thousands of sources emitting from 100 MeV to 100 GeV were discovered. The majority of the extragalactic ones belong to the class of jetted AGNs (blazars). Most of them are classified as BL Lac objects that are characterised by a quasi-featureless optical spectrum, which makes the determination of their redshift extremely difficult, preventing a full understanding of their intrinsic properties. At the present time about one third of the detected gamma-ray sources are still not associated to optical objects and their nature is unknown. Although most of these sources are expected to be blazars, one cannot exclude that some of these unassociated gamma-ray emitters hide new classes of objects. To investigate the nature of these gamma-ray sources, we are carrying out an extensive optical spectroscopical campaign, at the 10m Gran Telescopio Canarias (La Palma), to secure high S/N spectra of the optical counterparts. From these observations we were able to: i) classify several gamma sources; ii) determine new redshifts or set stringent limits for several targets; iii) provide good candidates for TeV observations (e.g. by MAGIC); iv) secure unprecedented high quality optical spectra of neutrino candidates (including the redshift of the first extragalactic source,TXS0506+056, associated to a neutrino by Icecube detection EHE170922A ). We present the results of this campaign covering about 100 targets in the context of emission models of the sources, the cosmic evolution of the blazar population and of the use of their GeV-TeV spectra to put sound constrains on the properties of the Extragalactic Background Light.