More people will continue to shift their spending online over the next several decades. E-commerce has been gradually gaining share of overall retail spending for years, but it still only makes up 20% of retail sales, according to eMarketer. Owning shares of e-commerce companies that will be part of this secular trend should thus pay off for investors.

Given the headwinds affecting online sales growth over the last year, now is a perfect opportunity to put some money to work in undervalued e-commerce stocks. If you have $500 or less, here's why you might want to consider splitting the amount between shares of Etsy (ETSY 0.34%) and JD.com (JD 6.12%) right now. 

Etsy

Shares of Etsy have fallen 79% from their previous high. Trading at just 13 times free cash flow (FCF), investors are getting a bargain for a profitable company with a long runway of growth. 

However, Etsy has admittedly reported sluggish top-line growth lately. In the second quarter, revenue was up 7.5% year over year, weighed down by a small dip in gross merchandise sales (GMS). Etsy has made up for the slower growth with a higher take rate, or the amount the company earns on each transaction in its marketplace. This has kept the top line rising despite the decline in GMS. 

Zooming out a few years, Etsy's business has grown tremendously with revenue and FCF per share up more than 240% since Q2 2019. And there's no other retailer or marketplace that offers the same assortment of handmade and custom merchandise. Moreover, the number of active sellers grew 12% year over year in the second quarter. As more sellers join the platform, it will expand the selection of items, improving buyer conversion and sales growth.

While many e-commerce companies have experienced a growth hangover in the wake of record consumer demand during the pandemic, Etsy still dominates its corner of the industry. Investors who are willing to patiently hold the stock through this slump can take advantage of the beaten-down share price.

JD.com

Shares of JD.com are off 74% from their previous peak. JD is one of the largest online retailers in China, which is a massive e-commerce market on its own. China's retail e-commerce sales were valued at nearly $2.7 trillion in 2022, and they're expected to reach nearly $4 trillion by 2027, according to eMarketer. 

China's retail market has recovered much more slowly than investors expected coming out of the pandemic lockdowns. Leading online retailers, including Alibaba and JD.com, have reported sluggish growth and their share prices have fallen to deeply discounted prices.

While JD.com's revenue has nearly doubled in the past four years, investors are concerned about near-term profitability as China's leading retailers race to offer bigger discounts to attract shoppers. The company has invested in a new low-price program, but this might be growing the perception that JD.com is sacrificing its long-term profitability for near-term sales growth.

However, management is absolutely focused on improving margins. FCF per share has more than tripled since 2019. While the retail segment's slight decline in operating margin last quarter is contributing to the recent slide in the share price, JD.com's improving efficiency with its supply chain is paving the path for more profitable growth over the long term. 

The market also underestimates other levers the company has to increase margins, such as its growing logistics services. This business made up 14% of total revenue last quarter, but the segment notched a significant jump in operating profit.

The stock trades at a ridiculously low price-to-FCF ratio of 11. This bargain valuation is based on JD.com's sluggish top-line growth in a challenging economic environment, but it places zero value on the company's margin expansion potential. At these low share prices, the long-term upside far outweighs the downside.