Walmart (WMT 0.46%) has quickly expanded to take the lion's share of online grocery sales through its curbside pickup and same-day delivery service. The company says curbside pickup will be available to 80% of the U.S. population by the end of the year thanks to its massive brick-and-mortar footprint. This year, 3,100 Walmart stores will offer curbside pickup.

Amazon.com (AMZN -2.56%) -- which dominates just about every other category of online retail -- doesn't have the same network of stores as Walmart. There are fewer than 500 U.S. Whole Foods Market locations, and they're largely concentrated in bigger metropolitan areas. But Amazon has two big competitive advantages over Walmart that have largely gone unutilized over the last two years following its acquisition of Whole Foods: It has better shopper data and more online traffic.

A woman pushing a shopping cart in front of a Whole Foods Market sign.

Image source: Amazon.com.

Paying customers for their data

Soon after Amazon acquired Whole Foods, it started introducing exclusive deals for Prime members. It also extended the 5% cashback rate on its co-branded credit cards to Whole Foods stores. Every time a customer uses his or her Prime membership or Amazon credit card at Whole Foods, Amazon gets some very valuable data.

Amazon can see what its Prime members are buying at Whole Foods. As a result, it knows exactly what to recommend to each shopper if and when they want to use Amazon's Prime Now two-hour grocery delivery service. Being able to quickly find their favorite items makes the first-time use of Prime Now's grocery delivery a more pleasant experience for shoppers compared to other platforms.

Walmart, by comparison, doesn't have a loyalty program. It launched Walmart Pay -- its own branded mobile wallet -- as an attempt to capture more data at the customer level, but it doesn't seem to have made much headway. It recently relaunched its store credit card with an incentive for cardholders to use Walmart Pay for 5% back in stores for the first year.

Amazon has built up a trove of data that makes the onboarding experience for new online grocery customers better than any competitor.

The best online real estate money can't buy

Amazon only recently starting promoting its grocery delivery service on its website. Previously, Prime members had to download the Prime Now app in order to access its catalog of items available for same-day delivery. After a successful test in a few markets, Amazon is expanding grocery ordering through its main website to 30 markets.

Every month, Amazon.com receives about 200 million unique visitors. The Prime Now app has about 1.8 million active users in August. The move to the main website will certainly help Amazon reach customers it wasn't, and the ability to capitalize on shopper data should help push sales.

Walmart also features its grocery service on its main website, but it's invested a lot in traditional marketing. It bought Super Bowl commercial time, sent out mailers, and ran various promotions to get customers to try its online grocery platform. The top-line results speak to the efficacy of its marketing, but it's certainly expensive. Walmart's advertising costs increased to $3.5 billion last year from $3.1 billion in fiscal 2018.

Fighting back against Walmart

Walmart has unique advantages of its own that, along with its marketing efforts, have enabled it to get ahead in the online grocery market. Walmart has invested a lot in online grocery, and with good reason. It accounts for 26% of grocery spending in the United States, so as consumers shift their spending online, it needs to ensure those dollars stay with its stores.

Amazon, meanwhile, is dominant in online retail, and Walmart's push with online grocery is a threat to its dominance in general merchandise. Walmart's planning to offer unlimited same-day grocery delivery to customers from 1,400 of its stores for just $98 per year. Its head of e-commerce says it's a loss-leading service designed to get customers used to shopping on Walmart.com instead of its competitors. Amazon would like to nip that offer in the bud by getting as many Prime members familiar with Prime Now grocery delivery as possible.