When investors think of tech megatrends, e-commerce is probably not the first thing to come to mind. Online retail may not be as sexy as emerging markets like artificial intelligence, cloud computing, virtual reality, or autonomous vehicles, but the long-term opportunity in e-commerce could be bigger than all of those nascent technologies. E-commerce has been revolutionizing the way consumers buy products for more than 20 years, but there is still plenty of growth ahead, especially in small-cap stocks.

A man holding a credit card and typing on his computer.

Image source: Getty Images.

What is e-commerce?

The simplest way to define e-commerce is the buying and selling of goods via the internet. With the advent of the internet in the mid-1990s, e-commerce started slowly, but it has gained momentum as technology has improved with advances like smartphones and delivery times have gotten faster as companies such as Amazon (NASDAQ:AMZN) and others have added hundreds of warehouses across the country in order to meet customer demand.

U.S. retail sales alone total more than $5 trillion a year, and that number approaches $6 trillion when restaurants are included. While e-commerce may seem ubiquitous these days, especially with the rise of Amazon, less than 10% of all retail sales take place online, meaning the U.S. e-commerce market today is worth about $500 billion. That leaves plenty of opportunity for growth, and e-commerce has steadily grabbed market share since the dawn of the internet, with sales increasing by about 15% annually since the financial crisis. Over the last 10 years, e-commerce's share of retail sales has grown from less than 4% to nearly 10%, and outside of the U.S. in markets like India and China, the opportunity may be even greater.

The growth of online retail should remain strong, as the advantages over traditional retail shopping are clear: Shopping from home or via a smartphone provides a degree of convenience unmatched by physical stores. E-commerce will also continue to get bigger, as new technologies will make it even more convenient, speed up delivery, and provide other advantages over shopping in a physical store. Many of the technologies listed above should help accelerate the growth of e-commerce.

Driverless cars, for example, will lower the cost of delivery by eliminating the need for drivers. Drones could also remove the need for vehicles for some deliveries, making the process even cheaper. Artificial intelligence is already helping warehouses become more efficient and speed up the picking and packing process. Cloud computing has helped online retailers easily scale up as they grow, and virtual and augmented reality have made shopping online for things like furniture easier, as shoppers can see images of how an item like a couch would fit in their living rooms.

Such technologies, along with the proliferation of smartphones and better internet connectivity, will also spur the growth of e-commerce in the developing world.

The many ways to play e-commerce

Though e-commerce may seem like a simple business model, there are in fact several different ways for investors to capture a piece of the opportunity, each with its own advantages and disadvantages. The table below shows the different ways to invest in the industry with the e-commerce companies that operate in each category.

Models What They Do Examples
Direct sellers Essentially like a physical store but operate online.
Direct sellers own their inventory and sell merchandise to customers.

Amazon
Wayfair (NYSE:W)
JD.com (NASDAQ:JD)
Stitch Fix (NASDAQ:SFIX)

Marketplaces Function as platforms that connect buyers and sellers, earning money by taking a commission on sales and providing other services for merchants.
Some e-commerce companies operate as both marketplaces and direct sellers.
Etsy (NASDAQ:ETSY)
eBay (NASDAQ:EBAY)
MercadoLibre (NASDAQ:MELI)
Amazon
Grubhub (NYSE:GRUB)
JD.com 
Alibaba (NYSE:BABA)
Software providers Provide cloud-based software that facilitates transactions and other functions like marketing, customer service, and sales management. Shopify (NYSE:SHOP)
Baozun (NASDAQ:BZUN)
Logistics/Delivery Bring goods to customers' homes. Often called "last-mile" delivery. XPO Logistics (NYSE:XPO) 
UPS 
FedEx 

Below, we'll take an in-depth look at each of these categories, examine the pros and cons, and discuss the best opportunities for investors.

Direct sellers

Direct selling is the simplest form of an e-commerce business. Direct sellers handle every aspect of the business, from stocking inventory to handling payments and customer service, shipping, and returns. They function much in the same way a brick-and-mortar store would, but instead of selling through a storefront, they sell through a website. Any entrepreneur can hang their online shingle out and begin selling products online, becoming a direct seller. Many of the companies that went belly up when the dot-com bubble burst like Pets.com and Webvan.com were direct sellers. In the fervor of the dot-com boom, venture capitalists and investors were throwing money at almost any online seller, convinced by the huge opportunity in online retail. However, building a viable e-commerce business turned out to be more difficult than expected, as online businesses face challenges like shipping costs and processing returns that stores don't have to deal with. Pets.com, in particular, met its fate partly because of the high cost of shipping heavy products like pet food, which proved to be ill suited to the online channel.

Even today, the model remains risky in that operators must take on the costs of inventory and shipping, and the cost of shipping, in particular, has made the online channel a lower-margin one than brick-and-mortar retail in many instances. A business's margin is simply the percentage of sales that it keeps as profit -- the higher the better. High margins are often a sign of underlying strength in the business, indicating that a company has a competitive advantage such as a well-known brand that gives it pricing power, allowing it to charge higher prices than competitors. Apple and the iPhone offer one example. Low margins, on the other hand, especially in businesses that have low or no growth, are a sign of weakness, which could come from poor management, operational problems, or a slew of other challenges. J.C. Penney, for instance, has lower margins than peers like Macy's and Kohl's because the company has struggled to win back customers after the disastrous Ron Johnson era

The table below shows the pros and cons of direct selling.

Pros Cons
High revenue and more market share Low or even negative profit margins
Control over all aspects of the businesses No benefit from third-party sellers
More likely to lead provide optionality/multiple futures Lack of competitive advantages

However, multiple success stories have come out of the direct-selling model, most notably Amazon. From its humble origins as an online bookseller, Amazon has grown to encompass myriad businesses, including cloud computing, an e-commerce marketplace, video streaming, and voice-activated search. It is now one of the most valuable companies in the world, but none of that would have been possible if it wasn't able to execute effectively as a direct seller, expanding its inventory, offering free and fast shipping through its Prime loyalty program, and gaining the trust of customers. In a unique way, Amazon has leveraged the power of its direct-selling business to overcome many of the cons listed above. The company has built competitive advantages through its Prime loyalty program and added a marketplace to give a platform to third-party sellers, which generates a higher margin for Amazon than direct selling. More than any other company, Amazon has shown how direct selling leads to optionality, or multiple futures, like entirely new businesses including cloud computing or video streaming. 

More recently, other direct sellers have risen to the forefront, including Wayfair and JD.com.

Wayfair is a furniture and home goods seller that was founded in 2002 and went public in 2014. The stock has more than tripled since its IPO as its revenue growth has surged, and revenue could approach $10 billion by next year. However, questions have arisen about Wayfair's ability to ever turn a profit, as the company has historically operated at a loss as it works to grow sales and build market share. Over its last four quarters, the company has lost $357 million. Meanwhile, competition from Amazon, which has historically operated its e-commerce operation near breakeven, has pressured profits at other e-commerce outfits and at brick-and-mortar retailers. Wayfair looks like a classic direct seller, according to the chart above, as the company has seen fast revenue and market share growth but is still unprofitable. Management continues to see a huge opportunity in e-commerce home goods and is willing to sacrifice profits in order to grow its top line. If or when that market finally matures, the company will need to focus on profitability.

JD.com, meanwhile, resembles the Chinese version of Amazon in many ways. The company is the leading online direct seller in China, ahead of Alibaba, but also operates its own marketplace, much like Amazon. In the first quarter of 2018, JD brought in $16 billion in revenue, $14.6 billion of which was from direct selling, and operating margins from direct selling were just 2.1%. Like Wayfair, the company is growing fast, with revenue up 44% in its most recent quarter to $16 billion. Unlike Wayfair, it is profitable, with $182 million in net income in the last year. With ambitions to expand into Europe and the U.S., JD could be the closest thing to another shot at Amazon for investors. Like Amazon, JD also has a marketplace for third-party sellers, as it's used its direct-selling platform for leverage. Its control over all aspects of its business has arguably given it an advantage over rival Alibaba because it's rapidly adding new warehouses to improve delivery times.  

Finally, there's Stitch Fix, a new kind of e-commerce business. The company is a styling service that sends customers a box of clothes, sometimes on a subscription basis, based on that customer's preferences. The customer keeps what they want and returns the rest. Stitch Fix uses technology and algorithms to help guide its buying and selecting process, as the customer's past choices inform future picks, and the company has emerged from a crowded field as the leader. It is profitable and putting up steady growth, with revenue up 26% in fiscal 2018, and the stock is up significantly from its $15 IPO price last November. The company appears to have many of the same potential competitive advantages and optionalities that Netflix has. For instance, Stitch Fix has already begun manufacturing and branding its own clothes, using its vast reams of data to its advantage. The company has also moved fast into men's, plus-sized, and kids' clothes and is preparing for a launch in the U.K. next year, its first international expansion.

Marketplaces

Of all the kinds of e-commerce businesses, marketplaces are the most common and arguably the most effective. Though there is some overlap between marketplaces and direct sellers, the two have distinct business models. Marketplaces function as platforms that connect buyers and sellers. In a marketplace, the business does not sell any of its own goods or services but takes a commission on sales. It also makes money from providing additional services like handling payments or processing fulfillment and shipping. Below are some of the pros and cons with investing in e-commerce marketplaces. 

Pros Cons
High-margin/low-risk, as company doesn't handle inventory Lower revenue, lower market share than direct selling
Helps create competitive advantages through switching costs and network effects Can be hard to break into
Easy to scale up Exposure to problems with third-party sellers like counterfeit goods or bad customer service

The best-known e-commerce marketplace is probably eBay. The auction-based online marketplace was born in the early days of the internet and was an e-commerce pioneer along with Amazon. While eBay is still a well-known e-commerce business, its cultural relevance has faded, as the company has not done enough to modernize its platform, and it's growing more slowly than the broader e-commerce industry. The stock has only achieved modest returns in the last five years, underperforming the S&P 500 at a time when many e-commerce stocks have soared. The company also owns the ticket-reselling marketplace StubHub and was the former parent of PayPal Holdings. PayPal has thrived since the 2015 spinoff, showing the power of payment platforms, arguably another investing angle of e-commerce. eBay, meanwhile, has been spinning its wheels.

eBay has been a classic beneficiary of the marketplace model. Its profit margins have long been high, but its slow revenue growth also shows the consequences of becoming too complacent with such a model. 

Etsy is another popular e-commerce site. In fact, Etsy is one of the highest-trafficked e-commerce sites in the U.S. The company occupies a unique niche in the market: It sells handcrafted products from artisans like jewelry, home decor, and greeting cards, functioning essentially as an online flea market or craft fair. That focus has set it apart from other online retailers and given it an advantage in some ways. The company has also managed to resist a challenge from Amazon, which pushed its competing service, Amazon Handmade, over the holidays in 2017. Etsy sales surged anyway, and it still maintained a majority of the market share in the segment.

Though Etsy struggled in its early years, as the company lacked focus and offered cushy benefits, over the past year, the stock has been on fire. New CEO Josh Silverman issued layoffs, cut costs, and refocused the company on growing gross merchandise sales, which have accelerated in each of the last four quarters. Etsy has not yet reached the profitability level of other marketplaces like eBay, but the company's specialization in handcrafted goods has made it unique and attractive to both buyers and sellers, giving it a competitive advantage and creating barriers to entry. 

Like Etsy, Grubhub stock has also been flying higher in recent months. The online restaurant takeout marketplace is the leader in its industry, fending off challenges from start-ups like DoorDash and Postmates, as well as more established competitors like UberEats and Amazon. The stock is up 133% over the last year thanks to both organic growth and smart acquisitions like its purchase of Eat24 from Yelp, which also included a strategic partnership with the recommendation engine. More recently, Grubhub became the exclusive delivery partner of Yum! Brands' restaurants KFC and Taco Bell, giving it access to more than 10,000 restaurants nationally. 

Grubhub continues to see its biggest whitespace opportunity as taking share from traditional delivery ordering channels like the telephone, and the company is adding new markets nationwide, moving away from its core cities like New York and Chicago. Last year, its net income doubled, and the company's profit margin reached 15%. That shows the power of the marketplace model and how Grubhub has leveraged network effects in its favor. Sellers want to be on the platform with the most buyers and vice versa. 

Finally, outside the U.S., there are two notable names worth considering as investments -- Alibaba and MercadoLibre. Alibaba is China's leader in online retail, operating marketplaces including Alibaba.com, Tmall, and Taobao. Alibaba.com is primarily geared at foreign shoppers, while Tmall is a platform for brands like Nike to sell in China, and Taobao more resembles eBay. Thanks to the rapid growth in Chinese e-commerce, Alibaba's sales have surged lately, with revenue jumping 58% to $39.9 billion last year. Adjusted earnings per share increased 32% to $5.24, or net income of $10.2 billion, giving it a hefty profit margin of 25.6%, once again leveraging the power of the marketplace model. Compared to JD.com, Alibaba's profits and margins show how a marketplace can be scaled up profitably in a way that direct selling cannot.   

South of the border, MercadoLibre has emerged as the leading e-commerce operator. The company connects buyers and sellers throughout Latin America and has recently switched up its strategy to offer more free shipping, aping Amazon in a move that seems designed to block out the e-commerce giant in markets like Brazil, where it has expressed interest. As a result, MercadoLibre's revenue growth accelerated to 66% last year, and the stock has more than tripled over the last three years. Again, the benefits of switching costs and network effects have helped MercadoLibre establish itself as the clear e-commerce leader in Latin America.

Software providers

Businesses large and small rely on software to run their e-commerce businesses, and there are two cloud-based providers, or companies who provide cloud-based software to run e-commerce businesses, that have emerged as promising investments: Shopify, which is focused on North America, and Baozun, which provides its service to companies in China. Again, let's take a look at the pros and cons in this sector.

Pros Cons
Offers broad exposure to e-commerce No direct connection to end consumer
Scalability High sales and marketing expenses to add customers
Competitive advantages through switching costs Profitability takes time

The advantage of investing in such software companies is that they allow investors to benefit from broad exposure to e-commerce, since a wide range of businesses use providers like Shopify and Baozun. Of course, those two face competition within their own industries, but they have emerged as leaders nonetheless.

Shopify, which is based in Canada, counts more than 600,000 small and medium-sized businesses as its customers, who use its services to organize their online storefronts, track and manage sales, help with marketing plans, and process payments. The company has four subscription levels -- the highest, Shopify Plus, costs $2,000 a month -- and caters to large companies like Nestle, Red Bull, and Unilever.

In part because of the growth of Shopify Plus, Shopify's revenue has continued to surge, increasing 73% last year to $673 million. Shopify has historically operated around breakeven, as the company's strategy has been to plow money into growth to gain market share first before focusing on profitability. Investors have been rewarded, as the stock has climbed nearly 500% since its 2015 IPO. Though concerns have arisen about its valuation, there are plenty of reasons to believe that Shopify can continue moving higher. Shopify benefits from switching costs, as it's difficult and highly inconvenient for e-commerce businesses to migrate to a new software system once they're up and running with Shopify.

Baozun has had similar success to Shopify. The young company has courted the likes of Microsoft, Nike, and Starbucks and gives investors exposure to the fast-growing Chinese market. Though Baozun is often compared to Shopify and is even called the Shopify of China, the company goes beyond Shopify's offering by providing services such as IT, warehousing, distribution, and customer service. Baozun has also steadily gained market share in China and controls about 25% of the e-commerce services market, nearly triple its nearest competitor. The company is gradually pivoting to higher-margin services rather than direct sales, as services revenue has been growing significantly faster than product revenue. The company is also modestly profitable, with a profit margin of about 3%. And, like Shopify, the stock is up more than 400% since its 2015 IPO. Baozun's market share gains demonstrate the company's competitive advantages, and its reputation continues to attract more multinational enterprises to its platform.

Logistics

Though smaller as an overall component of the e-commerce sector than the other categories above, delivery and logistics still deserves the consideration of e-commerce investors. Let's take a look at the pros and cons of this category. 

Pros Cons
Benefits from "picks and shovels" approach to e-commerce Heavy infrastructure costs
High barriers to entry Slower revenue growth than other e-commerce sectors

There's one logistics company in particular that stands out above the others as an intriguing e-commerce stock: XPO Logistics. The freight and logistics specialist is the leader in the last-mile delivery of heavy goods like furniture and appliances, making it a valued partner for retailers like IKEA, Amazon, and Home Depot. Home Depot even considered trying to acquire it, a sign of its value to such retailers. XPO shares have surged as the company and CEO Brad Jacobs have successfully executed a roll-up strategy, or acquiring smaller companies to build competitive advantages and eliminate competitors. 

XPO stock is up nearly 2,000% over the last 10 years, due in large part to Jacobs' strategy, which took the company from being a small logistics provider to the $13 billion industry leader it is today. E-commerce operators large and small rely on XPO for logistics, data analytics, and delivery, which are the "picks and shovels" of e-commerce. Much in the way miners in the gold rush relied on picks and shovels to dig for gold, so online retailers need shipping and logistics companies to ensure their merchandise reaches the customer safely and swiftly. 

Delivery will remain a crucial component of the e-commerce process, and even innovations like drones or autonomous vehicles are unlikely to disrupt the current system for delivering heavy goods. XPO is also focused on developing technology such as drones, so technological advances shouldn't disrupt its leadership. 

UPS and, to a lesser extent, FedEx both offer exposure to e-commerce logistics, but those companies also do significant business-to-business shipping, meaning XPO is the best way for investors to capture growth in e-commerce delivery.

The risks of investing in e-commerce stocks

The biggest risk in investing in e-commerce stocks is their valuations. With the exception of eBay, all of the stocks discussed above trade at steep price-to-earnings multiples, meaning that high growth rates are already priced in. Given the long trail of growth ahead for e-commerce with its steady annual growth rate around 15%, investors are valuing e-commerce stocks accordingly and have factored in those opportunities. 

That means that these stocks will be more volatile than the market average and could be especially vulnerable in a recession or another market crash, as many of them don't have significant profits to underpin their valuations. The optimism that's made many of these stocks outperform in recent years is also likely to disappear in the event of a correction or a bear market, much like other tech-based growth stocks

Therefore, e-commerce stocks are best suited to investors with longer time horizons who can more easily endure seeing such holdings potentially lose half of their value or more. Investors who depend on their portfolio for income or wealth preservation would be better off avoiding the sector or treading carefully in it, as it's considerably riskier than the broader market.

While it's almost certain that e-commerce itself will continue to grow, the same isn't true for e-commerce stocks due to their valuations. Though most of these companies should be winners over the long term, they are vulnerable to a pullback at any time.  

The best way to invest in e-commerce

For most investors, a basket of the stocks above is the best way to play the e-commerce space. A basket is just another way of diversifying, since owning several of the stocks above will give investors greater exposure to all aspects of e-commerce and mitigate some of the risk in owning these stocks. 

Your risk tolerance should determine your approach to e-commerce stocks; investors with a higher risk tolerance will find e-commerce stocks to be a better fit with their investing goals. Of the sectors above, marketplaces are the least risky. They are most likely to be profitable, have the strongest competitive advantages, and should be able to generate profits even in a down economy. Investors who are new to the sector would be best off investing in a marketplace operator and diversifying from there. It's also worth remembering that almost all of these stocks have outperformed the market in any given time frame in recent years, and considering the secular growth in e-commerce, they look poised to continue doing so. 

One thing is clear. With e-commerce giants like Amazon and JD.com continuing to make investments in things like warehouses, drones, and fulfillment and other advances in technology like voice ordering through Alexa, the ease and convenience of e-commerce will only grow. Online retail will eventually become a multitrillion-dollar market. For investors, there are plenty of ways to take advantage of this massive opportunity. 

John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Teresa Kersten is an employee of LinkedIn and is a member of The Motley Fool's board of directors. LinkedIn is owned by Microsoft. Jeremy Bowman owns shares of Baozun, JD.com, Match Group, Netflix, Nike, Stitch Fix, and XPO Logistics. The Motley Fool owns shares of and recommends Amazon, Baozun, Booking Holdings, JD.com, MercadoLibre, Netflix, PayPal Holdings, Square, Stitch Fix, and Wayfair. The Motley Fool has the following options: short September 2018 $180 calls on Home Depot, long January 2020 $110 calls on Home Depot, and short September 2018 $80 calls on Square. The Motley Fool recommends eBay, Etsy, FedEx, Home Depot, Match Group, Nike, XPO Logistics, and Yelp. The Motley Fool has a disclosure policy.