Walmart reporting its strongest growth in years last week was a tough act to follow, but Target (NYSE:TGT) proved up to the challenge Wednesday morning. The retailer put up spectacular second-quarter numbers, with both its stores and its online business booming. A combination of strong consumer spending, a flurry of new exclusive brands, and major e-commerce initiatives led to the best quarter for Target in more than a decade.

Getting shoppers in the door

Target reported total second-quarter revenue of $17.8 billion, up 6.9% year over year. Comparable-store sales rose 4.9%, driven by a 6.4% increase in store traffic. That's the strongest traffic growth number Target has posted since it began reporting traffic 10 years ago.

The exterior of a Target store.

Image source: Target.

Like Walmart, Target benefited from strong consumer spending. The U.S. Census Bureau reported a 6% year-over-year increase in adjusted retail sales for July, which likely provided some fuel for Target's exceptional quarter. This rising tide didn't lift all boats -- department stores like J.C. Penney and Macy's, for example, failed to benefit much from consumers opening their wallets. So Target certainly deserves some credit for its blockbuster results.

One thing driving Target's in-store sales is the collection of brands the company has launched since the start of 2017. Target has introduced more than a dozen new exclusive brands to its stores, with a few already on pace to produce more than $1 billion of annual sales. These brands help differentiate Target from the competition, giving shoppers a reason to visit its stores.

E-commerce bets paying off

Overall comparable sales grew by 6.5%, with digital sales growth running up the score. Comparable digital sales rose by 41% year over year, an acceleration from the 32% growth Target reported in the prior-year period. For comparison, Walmart, a company also investing heavily in e-commerce, reported online sales growth of 40% for the second quarter.

Target switched gears this year and became much more aggressive in the e-commerce sphere. The company started providing free two-day shipping on orders over $35, with no minimum for shoppers paying with a REDcard. It revamped its Restock next-day home essentials delivery service, slashing the fee to $2.99, or $0 for REDcard holders. And it expanded its Drive Up pick-up service and its grocery delivery service.

These investments are hurting the bottom line a bit. Target's gross margin declined by 10 basis points from the second quarter of 2017, with the company blaming pressure from digital fulfillment costs. Selling, general, and administrative costs also edged up as a percentage of revenue. But the impact so far has been small.

Profits and guidance

Strong second-quarter sales did wonders for Target's bottom line. Non-GAAP earnings per share rose nearly 20% year over year to $1.47, handily beating analyst expectations. A lower tax rate played a major role, with Target reporting an effective income tax rate of 21.8% in the second quarter. That's down from 31.4% in the same period last year.

Still, GAAP operating income rose 3.6% year over year. That growth is quite a bit slower than revenue growth thanks to the lower gross margin and higher costs. But it's not a bad result given the e-commerce push.

Target expects to produce EPS between $1 and $1.20 in the third quarter, representing year-over-year growth of around 20%. The company boosted its full-year EPS outlook to a range of $5.30 to $5.50, up from a prior range of $5.15 to $5.45. Comparable sales are expected to grow by roughly 4.8% in both the third quarter and the second half of the year, in line with the company's first-half results.

Firing on all cylinders

Target's second-quarter report should put to rest any concerns that the retailer is incapable of competing against Amazon.com. The company is successfully getting shoppers into its stores, and those very stores have enabled Target to quickly expand its assortment of online offerings. Target uses its stores to fulfill many online orders, giving it a network of mini distribution centers that even Amazon can't match.

I would expect Target's margins to continue to be pressured by the e-commerce push, but a lower tax rate will help boost the bottom line. Given how small of an online player Target is at the moment, the company should be able to sustain or even accelerate its online growth rate for years to come.

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Timothy Green 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.