Alibaba Group Holding Limited (NYSE:BABA) and Facebook (NASDAQ:FB) have been very rewarding investments for shareholders. Shares of Alibaba are up 88% over the last five years, trailing Facebook's return of 108%. Both companies benefit from network effects and are investing heavily in data centers and artificial intelligence to make smarter use of the data they each collect from their massive installed base of users. Data is as good as currency in today's economy, and Alibaba and Facebook possess a lot of it.

So, which of these two tech giants should investors buy today? We'll compare both stocks on a range of metrics to find out.

A woman's hand holding a smartphone with the symbol of a heart, a message bubble, and a thumbs up sign hovering over the screen

IMAGE SOURCE: GETTY IMAGES.

Financial fortitude

It's beneficial for a company to have plenty of cash on hand to fund future growth initiatives. This is particularly true in the fast-changing technology space. Of course, companies with plenty of cash resources are also able to reward shareholders down the road by initiating a dividend or share repurchases.

With that in mind, here's how both measure up on key financial metrics: 

Metric Alibaba  Facebook
Revenue (TTM) $51.91 billion $55.84 billion
Cash $29.16 billion $41.11 billion
Debt $19.78 billion $0.991 million
Free cash flow (TTM) $21.27 billion $15.36 billion
Free cash flow as a percentage of revenue 40.9% 27.5%

Data source: YCharts. TTM = Trailing 12 month.

The two companies look similar. Facebook has more cash and very little debt. On the other side, Alibaba generates higher free cash flow even though both companies generate about the same amount of annual revenue.

However, Alibaba's nearly $20 billion in debt leaves it somewhat handicapped relative to Facebook, which has virtually no debt. This gives Facebook greater financial flexibility, which can't be overlooked.

Winner: Facebook.

Which company is growing faster?

Alibaba has 699 million monthly active users across its retail marketplace, including the popular Tmall. The Chinese tech giant has a robust ecosystem of offerings, including cloud computing, logistics services, e-marketing, mobile payments, and video streaming. To give you an idea how dominant Alibaba is in China, the company has 58% market share of total e-commerce sales in China, while its next closest competitor -- JD.com -- has only 16%. 

Alibaba doesn't actually sell any goods but instead facilitates buyers and sellers, similar to eBay. The company's widely used commerce platform creates a massive data bank, which management uses to deliver high-value, data-driven marketing services to brands all over the world. 

On the other side, Facebook has more than 2.3 billion monthly active users worldwide. The social media giant generates 98% of its revenue from advertising, but it also produces a small amount of revenue from sales of Oculus virtual reality headsets and payments.

Here's a look at Alibaba's recent operating performance: 

Metric Fiscal Q3 2019 Fiscal Q3 2018 Change (YOY)
Revenue $17.057 billion $12.761 billion 34%
Free cash flow $7.472 billion $7.092 5%
Net income $4.504 billion $3.586 billion 26%
Non-GAAP EPS $1.77 $1.63 9%

Data source: Alibaba. YOY = year over year.

Here's a snapshot of Facebook's latest results:

Metric Q4 2018 Q4 2017 Change (YOY)
Revenue $16.914 billion $12.972 billion 30%
Free cash flow $3.318 billion $5.408 billion (39%)
Net income $6.882 billion $4.268 billion 61%
Pre-tax income $7.971 billion $7.462 billion 7%
EPS $2.38 $1.44 65%

Data source: Facebook. YOY = year over year.

In the latest quarter, Alibaba delivered better growth, overall. Facebook's net income grew faster, but that was mainly a result of a lower tax rate. Looking at pre-tax income, Facebook's growth was only 7%. Also, Facebook's free cash flow plunged 39%.

The social media giant's bottom line has been weighed down by concerns about privacy and security, causing the company to spend billions of dollars over the last year to shore up security on its social media platform. 

Alibaba's recent earnings growth was weighed down by losses in some of the company's consumer and logistic services, as well as investments in digital media, entertainment, and other strategic initiatives. 

The most significant risk for investors considering Alibaba is Chinese regulation and the recent volatility in China's economy. However, Alibaba's CEO Daniel Zhang assured investors on the latest quarterly conference call that "Chinese consumption growth is still strong, driven by a growing base of increasingly affluent young consumers." 

All in all, Alibaba gets the nod, here, as it's still posting higher growth rates than Facebook overall despite the softening in China's economy, which is a testament to the company's competitive position. 

Winner: Alibaba.

Check out the latest Alibaba and Facebook earnings call transcripts.

Valuation

Valuation is always an important metric to evaluate before making an investment decision. Comparing two stocks against each other can help guard against overpaying for a company's earnings. Here's how both stocks stack up on a range of popular valuation metrics: 

Metric Alibaba  Facebook
Market cap $444 billion $465 billion
Trailing P/E 49.07 21.54
Forward P/E 25.69 18.41
P/S ratio 8.675 8.483

Data sources: YCharts and Yahoo! Finance.

Facebook wins on every measure. The social media giant's stock looks compelling based on the company's 40% growth in earnings per share in 2018. Even though 2019 earnings growth is expected to drop off somewhat stemming from investments in security and data centers, Facebook should deliver comparable growth to Alibaba over the long term.

Winner: Facebook.

Facebook is the better buy

Both companies are facing challenges: Alibaba must navigate the unpredictable waters of China's regulatory environment, and Facebook's privacy issues are taking a bite out of its profitability right now. I view the China risk as a constant for Alibaba, whereas the security issues Facebook is dealing with will eventually move behind it once it finishes its current investment cycle.

There are risks on both sides, so I would buy Facebook because of its lower valuation and stronger financial position. Additionally, Facebook's efforts to ramp up e-commerce efforts on Instagram serve as an extra catalyst to long-term growth.