In the study of complex mammalian behaviours, technological limitations have prevented spatiotemporally precise control over intracellular signalling processes. Here we report the development of a versatile family of genetically encoded optical tools ('optoXRs') that leverage common structure-function relationships among G-protein-coupled receptors (GPCRs) to recruit and control, with high spatiotemporal precision, receptor-initiated biochemical signalling pathways. In particular, we have developed and characterized two optoXRs that selectively recruit distinct, targeted signalling pathways in response to light. The two optoXRs exerted opposing effects on spike firing in nucleus accumbens in vivo, and precisely timed optoXR photostimulation in nucleus accumbens by itself sufficed to drive conditioned place preference in freely moving mice. The optoXR approach allows testing of hypotheses regarding the causal impact of biochemical signalling in behaving mammals, in a targetable and temporally precise manner.