Movement links the distribution of habitats with the social environment of animals using those habitats; yet integrating movement, habitat selection, and socioecology remains an opportunity. Here, our objective was to disentangle the roles of habitat selection and social association as drivers of collective movement in a gregarious ungulate. To accomplish this objective, we (1) assessed whether socially familiar individuals form discrete social communities and whether social communities have high spatial, but not necessarily temporal, overlap and (2) modelled the relationship between collective movement and selection of foraging habitats using socially informed integrated step selection analysis. Based on assignment of individuals to social communities and home range overlap analyses, individuals assorted into discrete social communities and these communities had high spatial overlap. By unifying social network analysis with movement ecology, we identified state-dependent social association, where individuals were less cohesive when foraging, but were cohesive when moving collectively between foraging patches. Our study demonstrates that social behaviour and space use are inter-related based on spatial overlap of social communities and state-dependent habitat selection. Movement, habitat selection, and social behaviour are linked in theory. Here, we put these concepts into practice to demonstrate that movement is the glue connecting individual habitat selection to the social environment.