Tungsten trioxide (WO3) is an Earth abundant material of potential use as a light absorber for solar energy conversion processes. We carried out ab initio calculations of the band structure and absorption spectrum of WO3 using many body perturbation theory and we present a detailed comparison of our results with photoemission and absorption data. We show that it is necessary to take into account multiple effects, including spin-orbit and electron-phonon interaction, and exciton binding, in order to correctly predict the measured optical gap. The absorption spectrum obtained by solving the Bethe Salpeter equation compares well with experiments over a wide energy range, and our calculations correctly account for the red shift observed experimentally upon N2 intercalation in WO3.