We study the nature of long gamma ray burst (LGRB) progenitors using cosmological simulations of structure formation and galactic evolution. LGRBs are potentially excellent tracers of stellar evolution in the early universe. We developed a Monte Carlo numerical code which generates LGRBs coupled to cosmological simulations. The simulations allows us to follow the ormation of galaxies self-consistently. We model the detectability of LGRBs and their host galaxies in order to compare results with observational data obtained by high-energy satellites. Our code also includes stochastic effects in the observed rate of LGRBs.