Donald Trump has made no secret about his faith in media polling. He pointed to his winning results at every opportunity. But that may have also been his undoing and contributed to his second-place finish in Iowa.

Ted Cruz built a sophisticated turnout operation that contributed to his win, but Trump didn't seem to get the basics, as this tweet on Sunday from the Associated Press's Jill Colvin shows:

Trump baffled by rival campaigns' internal polling. "The networks do it for free. What the hell are they doing polling for?" — Jill Colvin (@colvinj) January 31, 2016

Candidates don't do internal polling in order to find out whom people plan to vote for. They do it to find their supporters and voters who could still be persuaded, and then get those voters to commit to them and cast a ballot.

Cruz's campaign gets this. Writing for Bloomberg Politics, Sasha Issenberg describes a campaign obsessed with data and analytics. Cruz was competing in a crowded field to get the support of evangelicals, and the campaign decided to find local and national issues that could motivate voters and tailor messages accordingly.

In some cases, that meant slicing voters into tiny groups, such as those who decided that repealing Iowa's ban on fireworks was the most important factor in their choice:

When there was no way that a segment could be rolled up into a larger universe, as was the case with the sixty Iowans who were expected to make a priority of fireworks reform, Cruz’s volunteers would see the message reflected in the scripts they read from phone banks, adjusted to the expected profile of the listener. A Stoic Traditionalist would hear that "an arbitrary ban of this kind is infringing on liberty," as a messaging plan prepared by Cambridge Analytica put it, while Relaxed Leaders are "likely to enjoy parties and community celebrations, such as the 4th of July, and thus a fun-killing measure of this kind is unlikely to sit well with them."

While Cruz was working on precise psychological profiling, the generally Trump-friendly New York Observer pointed out, the Trump campaign spent more on hats one quarter than on data analysis.

Go deeper: