Yes-associated protein 1 (YAP) is a transcriptional regulator with critical roles in mechanotransduction, organ size control, and regeneration. Here, using advanced tools for real-time visualization of native YAP and target gene transcription dynamics, we show that a cycle of fast exodus of nuclear YAP to the cytoplasm followed by fast reentry to the nucleus ("localization-resets") activates YAP target genes. These "resets" are induced by calcium signaling, modulation of actomyosin contractility, or mitosis. Using nascent-transcription reporter knock-ins of YAP target genes, we show a strict association between these resets and downstream transcription. Oncogenically-transformed cell lines lack localization-resets and instead show dramatically elevated rates of nucleocytoplasmic shuttling of YAP, suggesting an escape from compartmentalization-based control. The single-cell localization and transcription traces suggest that YAP activity is not a simple linear function of nuclear enrichment and point to a model of transcriptional activation based on nucleocytoplasmic exchange properties of YAP.