When it comes to the online battle for customers, two things matter -- convenience and price. Amazon.com (NASDAQ:AMZN) has long been seen as the clear leader in both categories, but now Walmart (NYSE:WMT) has reportedly nearly closed the gap when it comes to what people pay.

Across 21,000 products in grocery, beauty, and household supplies, Amazon still has cheaper prices than its chief rival, but it's only a slight edge, according to Profitero's Price Wars: Grocery, Household & Beauty report. The online giant is 1.8% less expensive for groceries and 2.6% lower for household goods. In beauty, Walmart has actually slipped behind its own Jet.com, which comes in second to Amazon by 1.4% for the June through August 2017 period studied.

"Our latest study confirms that price gaps in online grocery are much narrower than what we found to be the case across other non-grocery categories," said Profitero Senior Vice President Keith Anderson in a press release. "Walmart is clearly positioning to win shopper loyalty through aggressive pricing on everyday household essentials."

An Amazon tractor-trailer.

Amazon remains the online price leader, according to this study. Image source: Amazon.

Walmart is on the offensive...

Walmart has been making a big push to compete with Amazon. In grocery, its prices match its rival 67% of the time, according to Profitero, and across all three categories, it matches Amazon on 53% of products. 

"Amazon still reigns as the low-price leader online, but it's evident that Walmart is making grocery a key battleground for challenging that leadership," Anderson said.

...but Amazon has a secret weapon

While Walmart has closed the gap when it comes to Amazon's regular prices, it falls well behind the online leader's Prime Pantry service, according to this study. Available to Prime members, Pantry allows customers to choose among thousands of items. You buy items from this selection that will fit inside a 4-cubic-foot box that holds 45 pounds and get the box delivered for $5.99. Pantry Items are cheaper than they are on Amazon proper and the order ships via ground shipping, which takes one to four days, instead of the customary two-day shipping.

Prime Pantry prices on exact-matched items were almost 11% cheaper on average than prices at Walmart, Target, and Jet, according to the study. For comparable products, Target actually came closest to Prime Pantry, but it wasn't that close at 4.6% higher. Walmart's online prices were 10.3% more than Amazon's specialty service while Jet was 17.4% higher.

Overall, when comparing prices across all three categories and not factoring in Prime Pantry, Amazon still leads, with Walmart being 3% higher. Jet comes in 4.3% more expensive, and Target lags behind at 6.3% pricier, according to this survey.

Be a smart shopper

The high-level takeaway from this survey is that Amazon can cut online shoppers' bills, but there may be bargains at Walmart, Target, or Jet in specific cases. Comparison shopping can pay off, as can the use of Prime Pantry. Shoppers can also save money by going into a brick-and-mortar Walmart store to do their shopping. The chain has strategically made some common items less expensive in its stores in order to drive foot traffic.

In most cases, however, Amazon remains the price leader. Walmart is gaining ground, but it's not there yet and when you factor in Prime Pantry, it may not ever catch up.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Daniel B. Kline has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Amazon. The Motley Fool has a disclosure policy.