Online grocery sales were a key part to Walmart's (WMT -0.65%) phenomenal e-commerce sales growth last year. The company's online order and pickup service is now available in over 1,200 stores, and that'll reach 2,000 stores by the end of this year.

But if Walmart wants to meet its goal of 40% growth in online sales this year, it'll have to do more than that. That's why management has decided to roll out same-day grocery delivery to 100 markets by the end of the year, covering 40% of the U.S. population.

There's just one big problem standing in the way: Amazon.com (AMZN -1.14%).

Amazon is already the largest online grocery retailer in the country, selling twice as much as Walmart last year. After buying Whole Foods, Amazon is integrating Prime with Whole Foods in earnest this year. It's already offering Prime members free two-hour delivery on Whole Foods orders through Prime Now in six markets, with plans to keep expanding.

A Walmart associate weighing produce.

Image source: Walmart

Who is Walmart targeting with delivery?

Walmart and Whole Foods don't have a lot of overlap in their shopper demographics, so you might think that Amazon doesn't pose a major threat to Walmart's grocery business. But if you consider who Walmart is targeting with same-day delivery, it's probably going to start creeping into consumers that are more likely to shop at Whole Foods and Amazon.

Customers that want delivery are less price conscious and more focused on convenience. They are customers Amazon has already drawn into its Prime ecosystem.

Walmart's $9.95 delivery charge speaks to the convenience it offers through delivery. Walmart can offset some of that cost with lower average prices compared to Whole Foods, but the delivery charge represents a 25% markup on a $40 grocery order. That's about the same as the premium customers pay at Whole Foods compared to Walmart.

But if prices are roughly equal (after factoring in delivery costs), shoppers may still be more likely to choose Whole Foods over Walmart because of Whole Foods' brand association with higher quality. That means Walmart's delivery option might not have a very big impact on its online grocery sales.

Walmart won't prioritize growth over profits

Amazon has historically prioritized sales growth and bringing in new customers to its ecosystem over profitability. Walmart is unwilling to do the same.

One of the reasons for its disappointing online sales in the fourth quarter was its inability to keep everyday items in stock when it saw a surge in seasonal items over the holiday season. That's a problem that could've been solved by investing in fulfillment capacity or expediting shipping, but it would have eaten into Walmart's already shrinking gross margin.

Walmart is exhibiting the same hesitancy with grocery delivery. It will contract out the actual delivery to services like Lyft, Uber, and Deliv, and it's unwilling to eat any of the costs on those deliveries in order to increase sales. (Amazon also uses contractors for deliveries.)

Walmart may eventually bring grocery delivery in-house and slash prices, but its primary focus right now is to get delivery into as many markets as it can before Amazon. That might be shortsighted.

Online grocery sales are a key part of Walmart's 2019 guidance

Walmart said it expects to grow online sales 40% in fiscal 2019, even after posting growth of just 23% in the fourth quarter. Management noted the continued ramp up in online grocery will be a key part of reaching that figure by the end of the year.

In fact, management's comments indicate the expansion of online grocery to more stores will be the main driver of online sales growth this year. It expects a ramp up in year-over-year growth in line with the rollout of new stores into the online order and pickup program. CEO Doug McMillon warned investors won't see 40% year-over-year online sales growth in the first quarter.

The comparable growth numbers get easier as Walmart progresses through the year, but unless it does something to overcome Amazon's advantages in online sales (both grocery and general e-commerce), that 40% goal seems very high.