The past few years have been a wild ride for the e-commerce industry. The pandemic initially led to a boom in the sector, but things have cooled down significantly since 2021. Many e-commerce stocks have more or less followed this same trajectory. The good news is that this market has a bright future, regardless of short-term dynamics. According to some estimates, e-commerce will expand at a compound annual growth rate of 14.7% through 2027; it will likely stay northbound far beyond then.

Let's look at two stocks to buy to profit from this growth: Etsy (ETSY 3.38%) and Shopify (SHOP 1.80%).

1. Etsy 

Etsy is laser-focused on one specific niche of the e-commerce industry: the market for vintage and handmade goods. This strategy has been successful as Etsy has become one of the go-to platforms for buyers and sellers of these items. Building a reputation in this narrow pocket of a large sector helps attract interested customers through word of mouth.

However, there is a side to Etsy's strategy that poses a risk, especially in today's challenging environment. Vintage goods aren't cheap. With inflation still raging, consumers looking for ways to rein in spending could decide to cut back on these kinds of goods. That, combined with the slowdown the entire e-commerce market has experienced as people have returned to in-person shopping, has weighed on Etsy's financial results.

Still, the company is managing decent performance. In the fourth quarter, revenue increased by 12.6% year over year to $807.2 million. Net income decreased by 32.2% year over year to $109.5 million. Etsy's active buyers and sellers saw a slight drop, too, which isn't that surprising considering the abnormal increase these metrics saw earlier in the pandemic.

Zooming out helps. Etsy reports that compared to the end of 2019, it has 95% more buyers who are spending more per transaction and shopping more frequently on the platform. So although Etsy is facing near-term issues, the broader context of the unusual past three years helps puts things in perspective. The e-commerce specialist has generally increased all of its key metrics, and there are good reasons to think it can continue doing so over the next decade.

First, the value of Etsy's platform increases as more people use it since buyers and sellers will continue to look for one another. That's an example of the network effect, a potent competitive edge. Second, the business still has a long runway for growth. It estimates its total addressable market to be $2 trillion, of which it has grabbed a tiny portion. Making headway in this space will allow the stock to deliver solid results over the next 10 years.

2. Shopify 

Shopify started 2023 on fire after it announced it was increasing its prices for the first time in over a decade. Investors sent the company's shares soaring, an understandable reaction. Shopify's revenue growth dropped last year; the market had historically been forgiving of Shopify's net losses, but with decreasing top-line growth rates and a more challenging economic environment, that stopped being the case.

In the fourth quarter, Shopify's revenue came in at $1.7 billion, 26% higher than the year-ago period. The company's net loss of $623.7 million was much worse than the net loss of $371.3 million reported in the fourth quarter of 2021. Higher prices can help Shopify deal with the obstacles it currently faces -- inflation, difficult comparisons to the pandemic years, and higher expenses.

Management has tried to address some of these problems in other ways, for instance by decreasing its workforce to cut costs. Meanwhile, the business is also setting up a solid foundation for long-term success. Perhaps one of the more exciting developments it has been working on is its Shopify Fulfillment Network (SFN), which will help provide everything merchants need to deliver orders reliably, from storage to transportation. 

Shopify expects investment in SFN to affect its gross margins and operating expenses this year. But it will likely be worth it in the long run as quick delivery options can help merchants attract more customers, increase conversion, and generate higher sales, all of which will have a positive impact on Shopify's financial results.

Shopify also benefits from a competitive advantage: high switching costs. After spending a lot of time and effort building an online storefront and attracting customers, merchants aren't inclined to just close up shop and start from scratch on a competing platform. Doing so would be inconvenient, even beyond the risk of losing customers.

That's why Shopify can keep most of its merchants. Thanks to projects such as SNF, which render its platform even more attractive, it can continue gaining many new ones. And with e-commerce still growing, all these factors can help Shopify remain one of the key players in the industry for years to come while beating the market in the process.