Online grocery ordering has been a huge success for Walmart (WMT -0.65%). The retailer is rapidly expanding grocery pickup to more locations, with plans to reach 3,100 stores by year end, up from the 2,450 stores that currently offer the service. Digital sales, meanwhile, continue to climb, and are up 37% year over year in the first quarter.

Management called out online grocery as a key contributor to its e-commerce growth in its first-quarter earnings commentary. By next year, grocery could account for 33% of Walmart's digital sales according to analysts at Cowen and Company cited in a report by Grocery Dive. The strength in online grocery sales is particularly surprising considering Amazon's (AMZN -1.14%) efforts over the last two years following its acquisition of Whole Foods Market.

But Walmart's efforts haven't just halted Amazon's impact on its biggest business -- they've attracted new customers to the retailer that spend more per trip than in-store grocery shoppers.

A Walmart associate loading groceries into a car.

Image source: Walmart

Better than Prime?

Amazon has made several moves to integrate Prime and Whole Foods to offer more online grocery options for its customers. Prime members can pick up online orders from Whole Foods in 30 markets. Amazon also offers those customers free delivery; Walmart charges $9.95 per delivery.

Walmart, however, has been able to leverage its vast footprint of brick-and-mortar stores to enable customers to make pickup orders at about 2,450 stores, and order delivery from over 1,000 stores. By the end of the year Walmart will offer grocery pickup for about 80% of the U.S. population, and it'll deliver to about 50% of households.

That makes Walmart a more attractive option for most consumers in the country. In fact, 65% of Walmart's online grocery orders come from Prime members according to data from Numerator. Indeed, Walmart has managed to fend off Amazon's efforts to encroach on the biggest part of its business by creating an attractive service at an attractive price.

To be sure, Walmart's efforts in online grocery have had a negative impact on its profit margins. It offers similar prices in-store and online, but it has to hire personnel to pick items from shelves, pack them in bags, and bring them out to cars. It does that for no fee. The move is very Bezos-esque, and it's certainly paid off with greater sales.

Attracting new customers

Walmart's online grocery service has brought in a lot of first-time shoppers. Between 40% and 60% of pickup orders come from new customers according to Cowen and Company. Not only that -- those customers are big spenders. The average online grocery order totals nearly $125. That compares to just under $50 for a typical in-store shopping basket according to data from Numerator.

It appears Walmart is successfully attracting a new class of customer more interested in value and convenience than getting the lowest price. That's the same kind of customer that's likely to subscribe to Amazon Prime, and likely to spend more if it's convenient.

While online grocery sales might hurt Walmart's profit margins, bringing in these new customers has certainly helped. Gross margin was better than expected in the first quarter because the company saw better merchandise mix and better overall e-commerce margins -- not to mention comparable store sales improved 3.4% in the first quarter, the highest in nine years.

Walmart is successfully fending off Amazon and other competitors in the online grocery space. It's also doing well getting the new customers its online grocery service attracts to shop in other product categories.

That said, Walmart will have to keep investing in convenience in order to keep growing its online grocery business and the new customers that come with it. So investors shouldn't expect management to take its foot off the pedal, even after rolling out online grocery pickup to over 3,100 locations this year.