Motivated by recent trends in online advertising and advancements made by online publishers, we consider a new form of contract that allows advertisers to specify the number of unique individuals that should see their ad (reach) and the minimum number of times each individual should be exposed (frequency). We develop an optimization framework that aims for minimal under-delivery and proper spread of each campaign over its targeted demographics. As well, we introduce a pattern-based delivery mechanism that allows us to integrate a variety of interesting features into a website’s ad allocation optimization problem that have not been possible before. For example, our approach allows publishers to implement any desired pacing of ads over time at the user level or control the number of competing brands seen by each individual. We develop a two-phase algorithm that employs column generation in a hierarchical scheme with three parallelizable components. Numerical tests with real industry data show that our algorithm produces high-quality solutions and has promising run-time and scalability. Several extensions of the model are presented, e.g., to account for multiple ad positions on the webpage or randomness in the website visitors’ arrival process.