The dorsal root ganglia (DRG) contain the somas of first-order sensory neurons critical for somatosensation. Due to technical difficulties, DRG neuronal activity in awake behaving animals remains unknown. Here, we develop a method for imaging DRG at cellular and subcellular resolution over weeks in awake mice. The method involves the installation of an intervertebral fusion mount to reduce spinal movement, and the implantation of a vertebral glass window without interfering animals' motor and sensory functions. In vivo two-photon calcium imaging shows that DRG neuronal activity is higher in awake than anesthetized animals. Immediately after plantar formalin injection, DRG neuronal activity increases substantially and this activity upsurge correlates with animals' phasic pain behavior. Repeated imaging of DRG over 5 weeks after formalin injection reveals persistent neuronal hyperactivity associated with ongoing pain. The method described here provides an important means for in vivo studies of DRG functions in sensory perception and disorders.