The optimal number of products to offer consumers is one of the core strategic problems that firms face. This is increasingly so in digital markets where many firms offer a large product variety. In these markets, consumers purchase products repeatedly, making customer retention an important aspect for firm performance. In this paper, we study the interplay between these two variables, product variety and customer retention. First, we provide a novel game-theoretic model to analyze this interplay and also determine how the optimal product variety depends on the market environment. Second, we provide suggestive evidence for our theoretical predictions using data for video games from Steam. Our data set allows us to measure the key variables in our game-theoretic model and additionally contains plausible instrumental variables for empirical identification. We show theoretically that investment in product portfolio size and investment in customer retention are substitutes because the former increases demand from switching consumers whereas the latter increases the repurchase probability of current consumers. We then derive predictions on how market conditions determine a firm’s product variety, for which we find evidence in our empirical analyses: There is (i) a negative relation between product portfolio size and customer retention, (ii) an inverted u-shape relationship between market value and product variety, and (iii) a positive relation between consumer heterogeneity and product variety. Both our theoretical and empirical results are robust to a wide set of robustness checks.