To study how a firm can capitalize on a long-term customer relationship, we characterize the optimal contract between a monopolist and a consumer whose preferences follow a Markov process. The optimal contract is nonstationary and has infinite memory, but is described by a simple state variable. Under general conditions, supply converges to the efficient level for any degree of persistence of the types and along any history, though convergence is history-dependent. In contrast, as with constant types, the optimal contract can be renegotiation-proof, even with highly persistent types. These properties provide insights into the optimal ownership structure of the production technology.