Mobile app and camera company Snap (SNAP -4.04%) recently reported disappointing second-quarter results, and the market responded by sending its stock price down by about 40%. There was also collateral damage to companies that generate revenue from ads like Snap does. One stock that took a hit in the wake of that report was demand-side ad platform The Trade Desk (TTD -4.34%).

But is the whole digital ad space struggling, or are Snap's issues company-specific? Because of something that happened in May, I'm betting the problem is mostly Snap's. Here's why.

What happened last time

On April 21, Snap gave financial guidance for the second quarter, saying it expected year-over-year revenue growth in the 20% to 25% range and adjusted earnings before interest, taxes, depreciation, and amortization (EBITDA) of between $0 and $50 million.

Just four weeks later, Snap pulled that guidance, saying that "the macroeconomic environment has deteriorated further and faster than anticipated."

Investors didn't like the severity of this statement, nor were they pleased with how quickly management dropped its previous guidance. Needless to say, Snap stock was punished in the aftermath. But so were the stocks of many other companies that generate revenue from digital ads -- including long-term market-crushing investment The Trade Desk.

On May 26, three days after Snap's debacle, The Trade Desk published a press release of its own. But rather than pull its guidance as Snap did, The Trade Desk reaffirmed its guidance, suggesting management still believed it could grow its business in the current environment.

What's possibly happening this time

On July 21, Snap reported the Q2 results it had warned investors about. Revenues were only up 13% year over year, compared to the 20% worst-case scenario in the guidance it had pulled. Its adjusted EBITDA was $7 million, toward the low end of the range it had guided for.

More troubling than these headline numbers was Snap's monetization. Its user base grew, but average revenue per user was down 4% year over year to its lowest point in more than a year. Advertisers simply aren't spending as much on Snap right now.

Snap stock tumbled after it delivered those Q2 results. So did The Trade Desk. But I believe the market is throwing out the baby with Snap's bathwater.

The Trade Desk is not expected to report its second-quarter results until early August. The company guided for revenue of at least $364 million and adjusted EBITDA of $121 million, up 30% and 2.6%, respectively, on a year-over-year basis. This is the guidance it reaffirmed back in May.

Why this makes The Trade Desk a buy

My point is this: I believe the sell-off of The Trade Desk that was triggered by Snap's weak results was a mistake, and it has created a buying opportunity. 

Both of these companies make money from digital ads. But the mechanics are very different. Snap needs to attract users and keep them engaged so they can be shown ads. But advertisers can turn the spending dial up or down based on the results they're getting. And there's some reason to believe it's getting dialed down on Snap specifically.

For example, take a rival platform like Pinterest. From January through March, Snap's average revenue per user was only up 17% year over year. By contrast, Pinterest's average revenue per user was up by a more robust 31%. There are likely multiple contributing factors to this disparity, but it suggests that advertisers are spending more on Pinterest and cutting back on Snap.

However, they are still spending. And that's good news for The Trade Desk. The company works with more than one thousand agencies, which in turn are working with tons of brands looking to advertise their products. They may or may not advertise on Snapchat or Pinterest. But through The Trade Desk's platform, they're likely to find a suitable place to spend. 

I'm confident in The Trade Desk's long-term ability to grow its revenue for two reasons. First, the company has enormous reach. Consider connected TV, for example. In the U.S. alone, The Trade Desk estimates its platform allows advertisers to reach around 90 million households. And those television screens remain coveted destinations for advertisers.

Second, The Trade Desk is a leader not just in digital ads but in programmatic digital ads. Programmatic advertising is more targeted to its audience than non-programmatic digital ads. According to eMarketer, overall digital ad spend rose 30% in 2021, whereas programmatic ad spend rose 41%. In other words, programmatic ads are taking market share as advertisers discover the benefits of more targeted ads. That should provide The Trade Desk with a powerful tailwind.

Trading at a price-to-sales ratio of about 18, I won't call The Trade Desk a value stock. However, thanks to Snap, its valuation is below its 5-year average. That's not an opportunity that should be passed up, in my opinion.