In changing environments, phenotypic traits are shaped by numerous agents of selection. The optimal phenotypic value maximizing the fitness of an individual thus varies through time and space with various environmental covariates. Selection may differ between different life‐cycle stages and act on correlated traits inducing changes in the distribution of several traits simultaneously. Despite increasing interests in environmental sensitivity of phenotypic selection, estimating varying selective optima on various traits throughout the life cycle, while considering (a)biotic factors as potential selective agents has remained challenging. Here, we provide a statistical model to measure varying selective optima from longitudinal data. We apply our approach to analyze environmental sensitivity of phenotypic selection on egg‐laying date and clutch size throughout the life cycle of a white‐throated dipper population. We show the presence of a joint optimal phenotype that varies over the 35‐year period, being dependent on altitude and temperature. We also find that optimal laying date is density‐dependent, with high population density favoring earlier laying dates. By providing a flexible approach, widely applicable to free‐ranging populations for which long‐term data on individual phenotypes, fitness, and environmental factors are available, our study improves the understanding of phenotypic selection in varying environments.