Both Walmart (NYSE:WMT) and Target (NYSE:TGT) showed strong growth in online sales in the second quarter. Walmart's e-commerce sales increased 40% year over year, and Target grew digital sales 41%.

But the two still face a considerable challenge during the holiday shopping season from Amazon (NASDAQ:AMZN). Amazon has established itself as the first place most people search for products online thanks in large part to its Prime program, which offers unlimited two-day shipping.

Both Walmart and Target see fast and free shipping as a key way to differentiate themselves from other retailers when consumers are considering where to do their online holiday shopping. Here's how each expects to compete this year.

A person putting an item in a box with the target logo and free 2-day ship printed on it.

Image source: Target.

No membership required

Both Walmart and Target have offered free two-day shipping to customers for some time now. Walmart rolled out free two-day shipping on select items at the beginning of last year after its $50-per-year ShippingPass program failed to catch on. Target started offering its REDcard holders free two-day shipping on select items in March. Otherwise, both retailers require customers to purchase $35 or more in a single order to qualify for the shipping benefit.

The two are stepping up their efforts for the next couple months. From Nov. 1 to Dec. 22, all Target customers will be eligible for free two-day shipping with no minimum order amount. Walmart, meanwhile, is expanding the number of items available for two-day shipping by partnering with high-performance third-party merchants selling on its online marketplace. It will also make it possible for shoppers to return items bought from third parties at Walmart stores.

Both are touting the fact that there's no membership required, aimed at attracting customers that aren't willing to pay up for Amazon Prime. Amazon has increased the price of Prime membership for both monthly and annual members this year. That doesn't seem to have put too much of a dent in its customer base, but it's worth noting growth has slowed significantly over the past year.

Impacting the bottom line

Walmart investors should be hoping to avoid the missteps of Walmart's fourth quarter last year. The company saw a sharp drop in online sales last year, as it had trouble keeping popular items in stock. While it largely preserved its profit margin, it came at the cost of its top-line growth.

Target took the opposite approach. Digital fulfillment costs weighed on its gross margin in the fourth quarter, but the top line continued to climb. Target's new free shipping offer doubles down on what worked to grow online revenue last year, and Walmart appears to be along for the ride as well.

Target's stepped up its fulfillment capabilities over the past year, though, which could provide some relief from the increased expense in getting items to customers' doors quickly. The company stress-tested its system in July by offering tons of deals to shoppers during Amazon's Prime Day. The retailer said demand tripled its expectations, but it had no issues fulfilling orders in a timely manner. Target also added Shipt, which specializes in same-day deliveries, to its arsenal at the end of last year, and it's expanding its in-store fulfillment capabilities by hiring more seasonal workers.

Walmart's partnerships with third-party merchants for two-day shipping sounds similar to Amazon's Seller Fulfilled Prime program. Seller Fulfilled Prime requires third-party merchants to deliver items within two days, but gives them access to some of Amazon's logistics solutions and rates. Walmart may be giving merchants access to its shipping rates or otherwise subsidizing their shipping expenses. The latter would have a notable negative impact on its bottom line. Meanwhile, facilitating returns in store could have a slight impact on operating margin, as more personnel may be needed to handle increased returns.

Managing gross margin is a big challenge for both Walmart and Target as they look to compete for online sales. Investors should expect margin pressure over the next few months, but it could pay off with strong sales growth.