Recent studies in mice reveal widespread cortical signals during task performance; however, the various task-related and task-independent processes underlying this activity are incompletely understood. Here, we recorded wide-field neural activity, as revealed by GCaMP6s, from dorsal cortex while simultaneously monitoring orofacial movements, walking, and arousal (pupil diameter) of head-fixed mice performing a Go/NoGo visual detection task and examined the ability of task performance and spontaneous or task-related movements to predict cortical activity. A linear model was able to explain a significant fraction (33-55% of variance) of widefield dorsal cortical activity, with the largest factors being movements (facial, walk, eye), response choice (hit, miss, false alarm), and arousal and indicate that a significant fraction of trial-to-trial variability arises from both spontaneous and task-related changes in state (e.g., movements, arousal). Importantly, secondary motor cortex was highly correlated with lick rate, critical for optimal task performance (high d'), and was the first region to significantly predict the lick response on target trials. These findings suggest that secondary motor cortex is critically involved in the decision and performance of learned movements and indicate that a significant fraction of trial-to-trial variation in cortical activity results from spontaneous and task-related movements and variations in behavioral/arousal state.