"What was Nike thinking?" President Donald Trump said on Twitter last week about Nike's new ad featuring Colin Kaepernick.

A new poll may provide an answer.

Nike's decision to make the former San Francisco 49ers' quarterback a centerpiece of its 30th anniversary "Just Do It" campaign was a shrewd investment in its core customers: Younger Americans.

Among people ages 18 to 34, 44% supported Nike's decision to use Kaepernick, while 32% opposed it, according to an SSRS Omnibus poll provided exclusively to CNN. In the 35-to-44 age bracket, the decision earned support among a majority, 52%, compared to 37% who were against it.

Older adults were less supportive of the move: Only 26% of adults over 65 backed the decision.

But they are not Nike's base. Two-thirds of the company's sneaker customers are younger than 35, according to Matt Powell, a sports retail analyst at market research firm NPD Group.

Nike (NKE) carefully weighed its choices with Kaepernick, and placed a strategic bet on the athlete-turned-social activist.

Kaepernick— the polarizing quarterback who began raising awareness about police brutality and racial injustice by sitting and later kneeling during the national anthem at football games in 2016—announced the "Just Do It" ad with a photo on Twitter September 3.

"Believe in something. Even if it means sacrificing everything," he said. A television version of the ad, narrated by Kaepernick, first aired during the NFL's season opener last Thursday.

The ad provoked backlash from some who believe his protest during the anthem was disrespectful. Some people posted pictures cutting their Nike socks, burning their Nike shoes, and #BoycottNike started trending.

But the boycott proved fleeting and had no impact on half of Americans' views about the company, the poll found.

Nike's stock is up since Kaepernick revealed the ad. The company's sales online jumped 31% after it was released, according to one analysis by digital research firm Edison Trends.

Earlier this week, one investment analyst called the ad a "stroke of genius."

The ad resonated with Nike's customer base and bolstered its relationships with sponsor athletes such as LeBron James and Serena Williams, Camilo Lyon, an investment analyst at Canaccord Genuity, argued in a research report upgrading Nike's stock.

"This premeditated move was another subtle but significant sign of [Nike's] strength and confidence in its position in the marketplace, one that likely does more good than harm," he said.

The poll shows a sharp split along age, class and racial lines on Nike's ad campaign.

A plurality of poll respondents, 41%, opposed the company's choice of Kaepernick, while 37% supported the move. The rest were unsure.

But a majority of African-Americans and college educated Americans supported the ad. 68% of black people approved, while only 16% were against it.

The poll also reflects a deep divide over Kaepernick along familiar political lines, with 74% of Republicans opposed to the ad, while 64% of Democrats backed it. 42% of independent voters opposed it.

The poll was conducted by SSRS September 4 through 9 among a random national sample of 1,008 adults. They were reached by landline or cellphone by a live interviewer. The margin of sampling error for the poll is plus or minus 3 percentage points.

—CNN Polling Director Jennifer Agiesta contributed to this story.