We consider the problem of finding a strategy that tracks the volume weighted average price (VWAP) of a stock, a key measure of execution quality for large orders used by institutional investors. We obtain the optimal, dynamic, VWAP tracking strategy in closed form in a model without trading costs with general price and volume dynamics. We build a model of intraday volume using the Trade and Quote dataset to empirically test the strategy, both without trading costs and when trading has temporary and permanent effects, and find that the implementation cost is lower than the cost charged by brokerage houses.JEL classification: G12, G29, C61