This paper examines the determinants and margins of profit shifting through transfer pricing. We develop a theory model, where transfer pricing patterns are governed by a generalized concealment cost function (CCF). Our empirical analysis draws on microlevel data about transaction-level imports, firm-level characteristics, as well as tax differentials between regions in Switzerland and countries abroad. We find, both theoretically and empirically, that more productive multinational firms trade an increased quantity of goods, while deviating less from the arms’ length price. Moreover, the decision of firms to engage in transfer pricing depends negatively on a fixed cost component in the CCF, as well as trade costs. The model allows us to estimate a theory-consistent concealment cost function, which can be used for counterfactual analysis.