WASHINGTON—Mitt Romney's success in raising hundreds of millions of dollars in the costliest presidential race ever can be traced in part to a secretive data-mining project that sifts through Americans' personal information—including their purchasing history and church attendance—to identify new and likely, wealthy donors, the Associated Press has learned.

For the data-mining project, the Republican candidate has quietly employed since at least June a little-known but successful analytics firm that previously performed marketing...