Walmart (NYSE:WMT) is growing online sales faster than any other major competitor in the United States. The retail giant reported e-commerce growth of 43% for its fourth quarter and 40% for the full year last year. By comparison, Amazon (NASDAQ:AMZN), the market leader, grew its revenue from online sales in North America at about half that rate.

While Walmart's top-line growth is strong -- the company expects online sales to grow another 35% this year -- its bottom line is suffering as a result. The company is actually taking a loss on its online operations. Management expects those losses to get worse before they get better as the company invests in infrastructure, people, online grocery, and Store No. 8 initiatives.

Investors seem to have come to terms with the pressure on margins in the near term, but there's no guarantee Walmart will be able to overcome Amazon and other competitors to make its operations profitable.

A person's hands on the keyboard of a laptop displaying

Image source: Walmart.

Where's Walmart's online sales growth coming from?

The bulk of Walmart's online sales growth over the last couple years seems to stem from the grocery category. Walmart expanded online grocery pickup to over 1,000 more stores in fiscal 2019, reaching a total of 2,100 stores. It plans to add 1,000 more locations this year. Likewise, it expects to double the number of stores that deliver to customers' doorsteps to 1,600.

Groceries are generally extremely low-margin products. Add on top of that the costs associated with picking, packaging, and delivering a basket of goods to customers, and the profit quickly turns negative.

Walmart's strategy is to use the grocery business as something of a loss leader to drive repeat purchasers and produce sales in other, higher-margin categories. "The team is working with a great sense of urgency to increase sales in key areas like home and apparel, which will help margin rate as well simultaneously investing in new innovative solutions," CFO Brett Briggs said on Walmart's fourth-quarter earnings call.

When pressed on the call, CEO Doug McMillon noted sales of other categories, including sales from its acquired online brands, aren't coming in as quickly as anticipated. "The thing that's taking longer than what I would have guessed is to build that merchandise assortment, including the brands that we're trying to add, to a place where we got a repeatable healthy mix of business online," he said. "We're pedaling fast trying to make that happen and disappointed it's taken us long as it has."

Those other categories are areas where Amazon has historically dominated online sales. Walmart's progress in online groceries is great, but Amazon isn't so far ahead in the category that it's so difficult to compete. Building up home and apparel, as Briggs suggests, may not be as simple as expanding availability on

Check out the latest Walmart earnings call transcript.

What else is Walmart spending money on?

A big area of investment for Walmart last year was in fulfillment centers. Fulfillment centers are the backbone of a strong e-commerce operation, and Walmart faced substantial challenges in the fourth quarter last year because it lacked fulfillment capacity. It also made the mistake of subsidizing its fulfillment capacity by leaning on shipping and logistics partners at higher expense. That's something Amazon's done when sales grow faster than its fulfillment network can keep up with.

Building out greater fulfillment capacity will ensure Walmart has items in stock where they need to be in order to get the item to the customer in a timely manner. The company converted four Sam's Club locations into e-commerce fulfillment centers. It's also working with shipping partners to use some of its stores as fulfillment centers in densely populated markets.

All that comes at a significant cost. Walmart expects to spend $11 billion on capital expenditures this year, but it's only adding 10 new stores in the U.S. A lot of that money will go toward remodeling existing stores to enhance their abilities to fulfill online orders and building out its fulfillment network.

Greater fulfillment capacity means Walmart will be able to capitalize on opportunities like the one it saw with toys last quarter. (With Toys R Us out of business, there was a big opportunity to attract new customers.) But Walmart will still need to execute in driving customers to its website for items that don't end up in a pantry or refrigerator.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.