Target (TGT 1.03%) just posted extremely strong earnings results for its second quarter. Among the highlights was a 41% increase in comparable digital sales. That's an acceleration from the 28% increase the company posted in the first quarter as well as better than the 32% growth the company posted in the same quarter last year.

Target's digital sales are now growing just as fast as Walmart's (WMT 0.46%), which has invested heavily in acquisitions and building out its online grocery platform. Not to mention it grew much faster than Amazon (AMZN -2.56%), which remains far and away the market leader in digital shopping in the United States.

So, how did Target manage to accelerate digital sales to 41% last quarter?

A person holding a phone with the Target app loaded.

Image source: Target.

Who says Prime Day is just for Amazon shoppers?

Target dove headfirst into Prime Day this year. The shopping holiday was created by Amazon three years ago and has spurred online sales across the industry. Target's management said its participation in Prime Day resulted in sales that far exceeded its expectations.

The one-day sale in July was the company's "biggest digital sales day we've ever experienced outside of a holiday season, driving volume nearly 3x higher than our forecast."

Not only does the July sales day drive revenue for Target, it's also a key test of its ability to fulfill online orders when the busy holiday shopping season rolls around in November and December. That was one of the main reasons Amazon invented the shopping holiday.

Walmart found itself caught flat-footed in the fourth quarter last year, when it was incapable of fulfilling online shopping orders despite strong demand. That led to a marked slowdown in its online revenue growth, while Amazon and Target took up its slack. Testing in July helps protect the retailers from facing complications during the biggest shopping period of the year, when the stakes are much higher.

So, not only was Target able to drive more sales, it also showed that it's capable of fulfilling a lot of orders in a single day.

Investing in fulfillment is paying off

Target is investing in ways to fulfill orders. Not only is it successfully using its network of stores to maximize product availability and reduce shipping expenses, it's also investing in new ways for customers to shop online and get their items quickly.

Target bought Shipt, a same-day shipping company, at the end of last year. It has quickly expanded Shipt's presence to more than 160 markets, covering 1,100 Target stores. Shipt serves other stores as well.

Shipt memberships have more than tripled over the last year. Orders, revenue, and gross merchandise volume are all 2 to 3 times higher than this time last year. "We're seeing orders and GMV in comparable markets, meaning markets in which Shipt was already operating a year ago, that are up nearly 100% year-over-year," COO John Mulligan said on the company's second-quarter earnings call.

Target is also investing in a service it calls Drive Up, which allows customers to pick up online orders curbside. It's similar to Walmart's efforts in online grocery pickup, but it applies to all items in Target stores. Target has expanded Drive Up locations from 50 to more than 800 in the first half of the year. It expects to cover nearly 1,000 stores by the holiday season.

Target has also invested in its Restock service, which offers next-day delivery for home essentials like packaged food, toiletries, and office supplies. The service expanded nationwide in May, and the company cut the delivery fee from $4.99 to $2.99. If you hold Target's credit or debit Redcard, delivery is free.

Keeping margins in check

What's most surprising about Target's results is that despite its strength in digital, gross margin remained relatively stable. It saw a year-over-year decline of just a tenth of a percentage point despite a strong increase in fulfillment expenses and pricing pressure from its big one-day sales. For reference, Walmart saw its gross margin compress by a third of a percentage point year over year last quarter.

Management says it largely offset gross margin pressure with an increase in sales of its own private brands, another area of success for Target. Target is smartly reinvesting the additional profits it books from selling higher-margin products back into its digital sales efforts. The efforts are clearly paying off, and investors should expect digital sales to continue accelerating as it invests in more fulfillment capabilities.