No two tech giants may compete more closely than Facebook (META -2.15%) and Alphabet's (GOOG -1.00%) (GOOGL -1.05%) Google.

The two companies are far and away the global leaders in digital advertising, a fast-growing market that's expected to rise 17% to $327 billion this year, according to eMarketer. In the U.S., the size of the digital ad market recently topped traditional media like print and television, showing how much power Facebook and Google have.

Two hands holding different-colored marbles

Image source: Getty Images.

The two have different strengths in digital advertising, however. Google dominates with its search engine and properties like YouTube; Facebook, which also owns Instagram, excels with its vast user knowledge, which allows for precise ad targeting.

The strength of their models has driven fat operating margins at both companies, and the growth in the digital ad market has propelled shares of both companies higher in recent years. As the chart below shows, their stocks have outperformed the S&P 500 over the last five years:

FB Chart

FB data by YCharts.

With both companies coming off their first-quarter earnings reports, there's plenty of fresh news to dig into. Let's take a look at where each of the digital ad giants stands, to see which is the better buy today.

The ever-changing social network

Facebook has put a rough 2018 behind it, and seems to be in better shape these days. The stock has recouped last year's losses, surging 48% so far this year. And CEO Mark Zuckerberg has appeared to take the lessons of last year's Cambridge Analytica scandal and subsequent backlash to heart, as the company is focusing on making privacy central to its platform. Facebook is adding end-to-end encryption to all of its messaging apps; on the Facebook site, it's moving away from News Feed and toward features like groups, messaging, and video that foster direct interactions.

Meanwhile, in spite of Facebook's public hiccups, its ad business is as strong as ever. In the first quarter, revenue rose 26% to $15.1 billion; operating margin, adjusted for an expected fine of $3 billion to $5 billion from the Federal Trade Commission, came in at 42%; and adjusted earnings per share were $1.89, up from $1.69 in the year-ago quarter. While user growth has plateaued in North America and Europe, it's still growing quickly in the rest of the world, as total users were up 8% over the last year. The company's advertising business is also growing much more efficient; in North America, ad revenue per user in the quarter jumped 28% to $30.12.

Facebook warned that revenue growth would slow in the back half of the year. This is due to the effects of regulations like GDPR (the EU's General Data Protection Regulation) that have allowed users to opt out of ad targeting; growth in Stories, which monetizes at a lower rate than News Feed; and other product changes. The company also expects operating margin to narrow as it steps up investments in headcount, safety and security, and infrastructure.

Still, considering the company's growth, the potential of Instagram (which is still relatively unmonetized compared to Facebook), and profitability, the stock continues to look cheap at a price-to-earnings ratio of 24.9.

A sprawling tech giant

Alphabet has evolved in recent years beyond the confines of Google and its advertising business, which includes YouTube. The company's recent initiatives include its hardware business, with its Google Home smart speakers, Chromebook laptops, Chromecast streaming devices, Pixel smartphones, and Nest smart thermostat. Alphabet is also building out its cloud business, as it seeks to compete with Amazon and Microsoft, which have taken the lead in infrastructure cloud services. And it's seeing revenue growth from its app business, Google Play.

Meanwhile, Alphabet is plowing money into "Other Bets" like Waymo (its autonomous-vehicle business) and GV (its venture-capital arm). In the first quarter, it reported a loss of $868 million from Other Bets.

However, Alphabet's fortunes will continue to be determined largely by its ad business. The company gave investors a bit of a scare in its first-quarter earnings report: Growth in paid clicks decelerated significantly, coming in at 39% compared to 66% and 62% in the two previous quarters, and ad revenue increased just 15.3%. The stock gave up 7.5% as a result of the slowdown.

CFO Ruth Porat explained that the vast majority of clicks now come from YouTube, and that growth in YouTube "engagement ads" decelerated in the period because the company made changes last year to keep fake news and hate speech off the platform. Competition also seems to be having an impact on Alphabet, especially from Amazon, which has pushed aggressively into advertising over the last year.

The upshot seems to indicate slowing growth ahead for Alphabet, especially as its cost-per-click rate has long been declining; in the most recent quarter, it fell 19% from the year before. Alphabet still carries a reasonable price tag, though. Excluding nearly $7 billion in fines that the company has paid to the European Commission over the last year, the stock trades at a P/E of 26.1.

Which is the winner?

Facebook and Alphabet trade at similar valuations. Neither company's stock pays a dividend. Both have hoards of cash on their balance sheets. With their dominance in their respective areas of digital advertising, each commands significant competitive advantages. I think both stocks are good candidates to outperform the S&P 500 in the years ahead, as they have in the past.

But Facebook looks like the better bet of the two. The social network is growing faster than Alphabet, and has a more focused strategy than Alphabet, which sometimes seems to be throwing darts at a wall with its wide range of unrelated projects. Facebook's Instagram also gives it an edge, as that platform is still ramping up its user base; the popular photo-sharing app should drive growth in the years ahead.

While there are good reasons to own both of these stocks, Facebook seems more likely to outperform over the coming years.