With some macroeconomic indicators pointing to a recession, many companies will likely reduce their advertising spending to defend against the slowing economy. It's a characteristic we've seen in past recessions. However, we've also generally seen ad spending come roaring back when the economy recovers.

Knowing this, savvy long-term investors should be looking at the current situation as a great opportunity to pick up shares in advertising-focused stocks like Alphabet (GOOGL 1.27%) (GOOG 1.25%), The Trade Desk (TTD 4.15%), and PubMatic (PUBM 3.02%) at a discount. These three stocks are being heavily sold off because of short-term macroeconomic fears. Let's look at why that pessimism can be put to your advantage.

1. Alphabet

Alphabet is the parent company of three platforms that rely heavily on advertising revenue: Google, YouTube, and the Android operating system. About 80% of Alphabet's overall revenue comes from these business segments, making them vital to the third-largest U.S. company's bottom line. These segments perform so well because they tend to be premium platforms for advertisers interested in reaching their targeted audiences.

The broader fear of a drop in ad spend means companies need to focus what ad spending they do make in areas where it will be most effective. Basically, they need to try and get the most bang for their bucks. That's where Alphabet premium offerings have the advantage. During the last major recession, Alphabet's revenue hardly dipped, and the company maintained its strong profitability. Even during the COVID-19-induced recession of 2020, Alphabet's revenue remained steady.

GOOG Revenue (TTM) Chart

GOOG Revenue (TTM) data by YCharts.

In its second quarter, Alphabet reported revenue growth of 13% year over year, and its operating margin remained relatively resilient at 28%. These results keep with the trend of the company remaining strong during difficult economic periods.

As it cuts expenses and slows down hiring, Alphabet management is pivoting its operations to meet a challenging business environment. This seasoned management team knows how to navigate recessions, and the stock is poised to recover strongly when the economy recovers. 

2. The Trade Desk

The Trade Desk isn't a direct play on advertising like Alphabet. Instead, its software facilitates and manages the transactions between ad buyers and sellers. With The Trade Desk's analysis, advertisers can understand how their campaigns perform and adjust to target different audiences.

The Trade Desk began its operations just after the Great Recession, and the COVID-19 recession wasn't long enough to judge how it performed during stressful times. As a result, investors will have to trust management's ability to navigate the current environment.

The Trade Desk's management has worked to diversify revenue streams across multiple countries, giving it some resilience when one market slows. Analysts don't expect its revenue to slow down in its current quarter. The forecast is for sales to grow nearly 40% in Q2 and 36% in Q3. The fact that forecasts are calling for such growth in the current economic environment is encouraging and illustrates the company's potential.

Further underscoring that point is The Trade Desk's recent partnership with Walt Disney. This partnership should help advertisers more effectively automate targeted campaigns across Disney-owned web properties. In the long run, it could turbocharge growth for both companies.

The strong projected revenue growth and a big-time partnership bode well for the stock's long-term growth. Coupled with an expensive (but still reasonable for a fast-growing company) valuation of 54 times free cash flow, its current price could be a bargain.

3. PubMatic

While The Trade Desk works on the buy side of the programmatic advertising exchange process, PubMatic is on the sell side, helping buyers to access viewers in a targeted manner. While it offers many solutions, the area its management is most excited about is connected TV, which increased its run rate five-fold in Q1 compared to the prior-year quarter.

PubMatic grew its revenue in Q1 by 25% year over year to $55 million, while maintaining a 9% net income margin. Analysts project PubMatic will grow around 22% in the next two quarters, yet the stock trades for a bargain valuation of 15 times earnings.

PubMatic isn't very big, with a market cap of around $861 million. Still, it has the potential to explode higher and be a top-performing stock when ad buyers return in force to purchase the inventory that PubMatic is involved with selling.

Advertising spending will affect all three companies to some degree during 2022. How long it takes for the economy to recover is anyone's guess, but eventually, it will come back strong. It's nearly impossible to time a market bottom, so getting into these three stocks now gives investors the best chance to ride the recovery wave.