In recent primaries, two kinds of Republican voters have been seeing two different Mitt Romney video ads pop up on local and national news Web sites. The first, called “It’s Time to Return American Optimism,” showed the candidate on the campaign trail explaining how this was an election “to save the soul of America.” It was aimed at committed party members to encourage a large turnout. The second video ad, geared toward voters who have not yet aligned themselves with a candidate, focused more on Mr. Romney as a family man. Versions of the two ads were seen online in Florida, Iowa, New Hampshire and South Carolina. Kenneth M. Goldstein, the president of the Campaign and Media Analysis Group at Kantar Media, part of the advertising giant WPP, said Mr. Romney’s directed ads represented a sea change in political advertising. “Forty years ago, you’d watch the same evening news ad as your Democratic neighbor,” Mr. Goldstein said. The technology that makes such customized advertising possible is called microtargeting, which is similar to the techniques nonpolitical advertisers use to serve up, for example, hotel ads online to people who had shopped for vacations recently. In the last few years, companies that collect data on how consumers behave both online and off and what charitable donations they make have combined that vast store of information with voter registration records. As a result, microtargeting allows campaigns to put specific messages in front of specific voters — something that has increased in sophistication with the large buckets of data available to political consultants. Zac Moffatt, the digital director for Mr. Romney’s campaign, worked with a company called Targeted Victory for the online ads. “Two people in the same house could get different messages,” Mr. Moffatt said. “Not only will the message change, the type of content will change.” Few campaigns like to talk about this kind of advertising. Representatives from the Obama campaign and the Gingrich campaign would not confirm whether they were using targeted ads tied to voter data. Saul Anuzis, chairman of the Republican National Committee on Technology, said he expected spending on digital political ads to reach 10 to 15 percent of campaign budgets in the 2012 election season. Those numbers pale beside what campaigns will spend on television or direct mail. But the chief benefit of microtargeting is that campaigns can spend their money more efficiently by finding a particular audience and paying $5 to $9 per thousand displays of an ad, Mr. Anuzis said. “We can now literally target the household,” Mr. Anuzis said. Microtargeting is largely done by a handful of campaign consultant groups including Aristotle, CampaignGrid and Targeted Victory, which collect some of their data from direct marketing companies like Acxiom and Experian. The companies are reluctant to discuss which candidates are their clients, but according to a Federal Election Commission filing, CampaignGrid does work with the Ron Paul “super PAC,” Endorse Liberty. The process for targeting a user with political messages takes three steps. The first two are common to any online marketing: a “cookie,” or digital marker, is dropped on a user’s computer after the user visits a Web site or makes a purchase, and that profile is matched with offline data like what charities a person supports, what type of credit card a person has and what type of car he or she drives. The political consultants then take a third step and match that data with voting records, including party registration and how often the person has voted in past election cycles, but not whom that person voted for. Throughout the process, the targeted consumers are tagged with an alphanumeric code, removing their names and making the data anonymous. So while the campaigns are not aiming at consumers by name — only by the code — the effect is the same. Campaigns are able to aim at specific possible voters across the Web. Instead of buying an ad on, say, The Miami Herald Web site, a campaign can buy an audience. Another advantage is that these ads can be bought quickly — using an auction process to obtain ad space — when campaigns need to move rapidly to aim at an audience, for example, to counter a bad debate performance or an unflattering newspaper article. “If you can get in front of a news story, if you can help frame the debate rather than respond to the debate,” Mr. Anuzis said, “that makes a big difference.” John Simpson, media director at Blue State Digital, which worked with the Obama campaign in 2008, said bidding technology means strategists can “get a campaign up and running very fast and also potentially pull it down very fast.”