There's a considerable shift in people's behavior these days: More and more shopping and entertainment are taking place online. And as people spend more time and money online, advertisers are quickly following them there.

Two companies seeing substantial benefits from that shift -- or perhaps causing it in the first place -- are Amazon (NASDAQ:AMZN) and Facebook (NASDAQ:FB). Both have grown to become giants in their spaces: Amazon in online retail and cloud computing, Facebook in digital advertising.

Investors would do well with either company in their portfolios. (In fact, I own shares of both.) But if you had to choose just one, which makes the better buy: Amazon or Facebook?

Amazon packages being loaded onto an Amazon airplane

Image source: Amazon.

The everything, company

After humble beginnings as a bookstore, Amazon quickly expanded to different verticals, and now you can buy just about anything on Amazon's marketplace. There are over 100 million items eligible for two-day shipping to the company's 100 million Prime members.

But Amazon's no longer just a retail company. In fact, more than half the stuff sold on Amazon comes from third-party merchants simply using Amazon's marketplace to reach an audience. Amazon's third-party seller services climbed 39% year over year to $9.3 billion in the first quarter; Amazon's own online sales increased just 13%, by comparison.

Amazon also has a number of services that are rapidly growing. Subscription services revenue climbed 56% year over year in the first quarter. The segment encompasses Prime, Prime Video, Music Unlimited, Audible, and several other subscription offerings. The "other" revenue segment, which mostly consists of Amazon's advertising business, climbed 73% year over year on an adjusted basis.

And don't forget about Amazon Web Services, Amazon's cloud computing division. AWS accelerated its growth in the first quarter, up 49% year over year. Amazon also breaks out its operating profits from the segment, which climbed 57% year over year, as the company saw improved leverage with its growing scale.

While Amazon's retail business isn't growing as fast as it once was, its services businesses are booming. And Amazon's services are where the profits are. AWS, for example, produces an operating profit margin of 26%. Amazon's ad business could generate an operating profit margin of over 50%, based on results from Facebook. Considering Amazon's core operating margin is so slim -- less than 4% -- these fast-growing services will have a major impact on Amazon's bottom line.

The entrance to Facebook's campus

Image source: Facebook.

The social network

Just like Amazon, Facebook is exhibiting significant growth at scale. Over the last five quarters, Facebook's namesake service has added more daily active users than Snap's Snapchat has in its over-six-year existence, and it added the same number of monthly active users as Twitter just reported in its first-quarter results -- 336 million. Facebook's user base is growing faster than it has any business growing, considering there are now about 2.2 billion users on its platform.

Facebook CFO Dave Wehner has been warning of a significant slowdown in advertising revenue since 2016, due to supply constraints in Facebook's News Feed. But when it came time for that slowdown in the second half of 2017, it never showed up. Facebook found that its advertisers were willing to spend more on its ads, even as it faced short supply. Facebook's average ad price increased 39% year over year in the first quarter on top of an 8% increase in impressions. Overall, ad sales increased 50% year over year in the first quarter, an acceleration from the fourth quarter.

Not to mention that Facebook still has a lot of levers to pull. Instagram is still growing, and while ads in that feed now represent a significant portion of revenue, there are 300 million people using Instagram Stories every day -- and Facebook is only just starting to monetize the product.

WhatsApp Status (the WhatsApp Stories product) has even more users than Instagram Stories, and it remains completely unmonetized. And Facebook just released WhatsApp for Business in January, and already has 3 million users signed up. The company is on the verge of generating significant revenue from WhatsApp and its 1.5 billion users.

There's also Messenger, which has about 1.3 billion users of its own that Facebook has yet to fully monetize.

With a core business that's expected to produce around $55 billion in high-margin revenue and growing 50% year over year, plus a portfolio of some of the most popular social apps in the world, Facebook is also well-positioned to grow earnings for investors for a long time.

Which is a better buy?

Most "better buy" articles include a look at valuation to determine which stock offers better value to investors right now. That's great for comparing most companies, especially those that operate in similar industries. But here, it's not as useful.

Not only do Amazon and Facebook operate in different industries, but Amazon's focus on driving scale instead of profits makes the stock practically impossible to value using traditional ratios like price to earnings, enterprise value to EBITDA, price to free cash flow, or even price to sales.

Amazon is currently plowing more cash than it generates into technology to support AWS, building out new fulfillment centers and acquiring assets to support its logistics network, and paying for content to support its subscription services. Over the last 12 months, Amazon's free cash flow, less finance lease principal repayments and assets acquired under capital leases, was negative $3 billion. And Amazon even says its long-term goal is to optimize for free cash flow.

Still, it's hard to argue with the results on Amazon's top line and across all of its various segments. And so long as Amazon continues delivering results like it did in the first quarter, investors should be happy to see it burning through cash and eating into profits.

So, it's easy to see how traditional valuation metrics don't apply to Amazon. And comparing Amazon to Facebook stock in terms of valuation won't get us anywhere.

Perhaps the best way to determine which is the better buy is to consider the businesses themselves. Facebook is one of the best pure plays in the growth of digital advertising, with a strong moat and a handful of extremely popular platforms. Amazon, by comparison, has its hands in several growing industries: online retail, cloud computing, streaming media, and even a bit of digital advertising itself. And it's got a pretty good competitive advantage in all of those areas.

For an investor looking for a more diversified company that still has a ton of growth potential, Amazon stock looks like a better buy.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.