Check out the latest Amazon and Walmart earnings call transcripts.

When (NASDAQ:AMZN) announced its acquisition of Whole Foods Market in the summer of 2017, Walmart (NYSE:WMT) investors got worried. Amazon has a penchant for cutting margins to the bone in an effort to take market share, and the grocery business has thin margins already.

However, Walmart stepped up to the challenge. Not only did it defend its market share in traditional brick-and-mortar grocery sales, but it also accelerated its investments in digital grocery sales with great success. Amazon has historically led digital grocery sales, thanks to its overall dominance of online commerce; it took an 18% share of the market in 2017 compared to Walmart's 9%. But Walmart is shrinking the gap, and even surpassing Amazon by some measures.

A man wearing a green vest loads groceries into the back of a car.

Image source: Walmart.

Where are consumers shopping online?

Over the past year, consumers' destinations for online grocery shopping have shifted considerably. A survey from The Retail Feedback Group asked online grocery shoppers where they made their most recent purchase:

Grocery Provider









Supermarkets and food stores






Data source: The Retail Feedback Group via eMarketer.

Over the past year Walmart has stepped up its expansion of online grocery order and pickup. It now offers the service at over 2,100 locations throughout the United States, and 600 of those stores offer home delivery. Walmart has also invested in marketing the service via television commercials and mailer coupons.

The investments have paid off. Walmart is winning customer clicks, and they're coming at the expense of Amazon. Amazon may be growing its online grocery sales, but Walmart is growing faster and winning more new customers. That's corroborated by an October statement from Deutsche Bank analysts that Walmart had an 11% share of the market. The analysts expect its share to climb to 17% by 2025, although that would still trail Amazon's 19% share.

Amazon is prepared to fight back

Walmart's biggest advantage over Amazon is its proximity to shoppers: There's a Walmart location within 10 miles of 90% of the U.S. population. By comparison, Amazon has just 450 Whole Foods stores, largely concentrated on the coasts and in urban areas. But Amazon is planning an expansion of the Whole Foods footprint in 2019.

The company's late arrival to the bricks-and-mortar business could prove fortuitous long term. Amazon has the ability to design new stores with online ordering in mind. Amazon's current plans include extra storage space in new stores to help fulfill Prime Now orders.

Amazon is also considering expanding its Amazon Go concept to reach as many as 3,000 locations by 2021. Those locations could provide a boost to Amazon's grocery business by providing plenty of shopper data it can use to direct customers to other grocery products when they log onto Amazon.

Amazon's physical footprint expansion is necessary if it plans to compete in the digital grocery market. Shoppers have shown a preference for the click-and-collect model, as it allows them to examine their items before completing a transaction. It also means they don't have to sit around the house waiting for a delivery during a two-hour window.

Walmart was quick to leverage its physical footprint to grow its presence in digital grocery sales. With a footprint 10 times larger than Whole Foods', Walmart may see the benefits of its brick-and-mortar stores in online grocery sales for years to come. Walmart has certainly become a much bigger competitor in the space in just the last year and a half -- but Amazon is fully capable of fighting back.

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.