New York CNN Business  — 

Walmart is serious about giving Amazon a run for its money online. It’s so determined that the company bought a startup to help it compete in an unexpected business: online advertising.

The retailer on Thursday bought Polymorph Labs, a Silicon Valley startup that specializes in managing digital ads for brands. Terms of the deal were not disclosed, but Walmart said adding the startup’s technology would enable current and potential advertisers to reach consumers more effectively.

The acquisition positions Walmart to compete with Amazon (AMZN), which became the country’s third largest ad platform last year behind Google (GOOG) and Facebook (FB).

“Our data has never been monetized, and we have a tiny ad business,” Walmart CEO Doug McMillon told analysts last year. “It could be bigger.”

Walmart hopes its pitch to consumer brands will stick. It’s playing up the fact that it has a huge network of physical stores that it can use to recruit brands. Walmart says it has a trove of shopper data because 90% of America shops at Walmart every year, and its website and stores attract nearly 160 million visitors a week.

“We can help brands understand if someone saw their ad on Walmart’s platform or across the [internet], and then purchased the product in-store or online,” said Stefanie Jay, vice president and general manager for Walmart Media Group.

Walmart’s “scale and data could give it a unique opportunity to expand” its ad business, UBS analyst Michael Lasser said in a research report last month.

Walmart wants to squeeze out more digital advertising dollars because its profit is under pressure.

The company sold $184 billion worth of groceries in the United States last year, more than a third of its more than $500 billion in sales. But groceries carry razor-thin margins. Walmart has also sacrificed profit in recent years by investing billions of dollars to build out its digital operation, lower its prices and add online pickup to thousands of stores.

Profit has fallen three years in a row.

But Walmart believes that building new revenue streams, such as advertising, health care and financial services, can help offset its heavy spending and boost profit.

“Retailers will need to innovate and find new profit pools,” Lasser said. “Pivoting traditional retail business models won’t be easy, but will be necessary over time.”

The retailer faces challenges, however. Walmart chief financial officer Brent Biggs told analysts at a conference last month that Walmart needed to be careful to prevent its website from becoming “cluttered” with ads.

Rival grocers and retailers that want to expand their digital ad businesses also pose an obstacle for Walmart. Last year, Kroger (KR), Albertsons and Ahold Delhaize all made big pushes into advertising.

Kroger, for example, believes it has an opportunity to sell brands ads on its store shelves, and it’s tapping Microsoft (MSFT) to help. The two companies struck a partnership in January to pilot two stores in Ohio and Washington State. Instead of paper tags for prices and promotions on the two stores’ shelves, they will be digital. That creates room for Kroger to sell advertising space to brands.