It can be tough to put money in the market when stocks are falling like they have this year, but every investor would love the chance to go back in time and buy more stocks in 1974 or 2008, right before the market went on to reach new highs.

The steep sell-off in e-commerce stocks this year might provide a similar opportunity. Allocating a small percentage of your portfolio to leading names in e-commerce could prove to be a brilliant move down the road. Here's why I would put my money on Wayfair (W -0.02%) and Alibaba (BABA 0.09%).

Wayfair is cornering the online home goods market

Wayfair has emerged as a major brand in the $800 billion home goods market. Ongoing marketing efforts are fueling the increase of Wayfair's consumer mindshare and contributing to the company's tremendous growth over the last decade. Revenue has surged from $2.3 billion in 2015 to $12.7 in the past year. However, worries over a recent slide in revenue amid a weakening economic backdrop have sent the stock down over 80% year to date.

The stock trades at a very low multiple of its revenue -- not even 0.3 times sales -- so as Wayfair improves its profitability, investors should score a market-beating return from these low share prices. During the second-quarter earnings call in August, management said it would begin to steer the business back toward profitability in 2023.  

The ability to gain market share is still a big opportunity for the company long term. Wayfair stands out from the competition with millions of products sourced from more than 23,000 suppliers. 

Meanwhile, Wayfair's market cap has fallen from its peak of more than $35 billion to just $3.8 billion as of this writing. Though its free cash flow has trended downward from $1.1 billion in 2020 to negative $764 million in the past year, management is focused on guiding the business back to positive cash flow in 2023. Investors should buy this stock while it's still a bargain.

Alibaba leads in China

China's high-growth tech stocks have been slammed over increasing scrutiny from regulatory authorities over the last few years. Many of these companies also faced the possibility of being delisted from U.S. exchanges for not complying with the Securities and Exchange Commission's auditing rules.

Alibaba agreed earlier this year to work with U.S. regulators to maintain its listing on the New York Stock Exchange, but a slowing Chinese economy has also weighed on growth for the company's e-commerce marketplaces. This combination of headwinds has sent shares of one of the most dominant tech companies down 60% over the last year.

In addition to the regulatory and regional obstacles, the market is trying to reassess Alibaba's prospects in a weakening global economy. The company's retail businesses reported a revenue decline of 1% in the second quarter. However, this was partially offset by stronger growth in the cloud segment where Alibaba is the No. 1 cloud services provider in China. 

Alibaba's retail marketplaces face increasing competition, but its online stores like Taobao, Tmall, and 1688 still position the company in the driver's seat of the Chinese digital economy. The company has used its massive cash reserves to reinvest in other markets such as healthcare, logistics, and digital entertainment. Some of these businesses are not profitable, but altogether, Alibaba generated $22 billion in free cash flow on $132 billion in revenue over the last four quarters. 

Meanwhile, the stock trades at just 8.2 times trailing free cash flow. The regulatory headwinds and slowing economy are near-term risks, but at this valuation, investors are being well compensated for buying the stock.

Moreover, management is focused on optimizing the company's cost structure to improve profit margins. Progress here, combined with a recovery in consumer spending, will eventually lead the market to recognize the tremendous value underlying the stock right now.

When Alibaba was growing faster in a healthier economy, the stock traded at over 20 times free cash flow. A small investment as part of a diversified portfolio makes sense at this attractive valuation.