Many animals socialize in two or more major ecological contexts. In nature, these contexts often involve one situation in which space is more constrained (e.g. shared refuges, sleeping cliffs, nests, dens or burrows) and another situation in which animal movements are relatively free (e.g. in open spaces lacking architectural constraints). Although it is widely recognized that an individual's characteristics may shape its social life, the extent to which architecture constrains social decisions within and between habitats remains poorly understood. Here we developed a novel, automated-monitoring system to study the effects of personality, life-history stage and sex on the social network structure of a facultatively social mammal, the California ground squirrel (Otospermophilus beecheyi) in two distinct contexts: aboveground where space is relatively open and belowground where it is relatively constrained by burrow architecture. Aboveground networks reflected affiliative social interactions whereas belowground networks reflected burrow associations. Network structure in one context (belowground), along with preferential juvenile-adult associations, predicted structure in a second context (aboveground). Network positions of individuals were generally consistent across years (within contexts) and between ecological contexts (within years), suggesting that individual personalities and behavioural syndromes, respectively, contribute to the social network structure of these free-living mammals. Direct ties (strength) tended to be stronger in belowground networks whereas more indirect paths (betweenness centrality) flowed through individuals in aboveground networks. Belowground, females fostered significantly more indirect paths than did males. Our findings have important potential implications for disease and information transmission, offering new insights into the multiple factors contributing to social structures across ecological contexts.This article is part of the theme issue 'Interdisciplinary approaches for uncovering the impacts of architecture on collective behaviour'.