PubMatic (PUBM 0.33%) and its programmatic advertising platform helps publishers and app developers maximize the revenue they generate from selling ad space. The company offers a valuable service for its publisher customers, freeing them from having to sell ad space directly. And for ad buyers, including demand side platforms, advertisers, and agencies, PubMatic offers a broad set of ad inventory from roughly 1,600 publishers spanning a wide array of content verticals.

Up until recently, PubMatic was growing at a brisk pace. But the advertising business ebbs and flows with the state of the global economy. When economic uncertainty ramps up, some advertisers tighten their belts and slow down spending. For PubMatic, which takes a cut of the revenue generated for publishers, a slowdown in advertising activity will hit the top and bottom lines.

PubMatic expects its revenue in the fourth quarter to be approximately unchanged compared to the same period last year, a stark change from the double-digit growth the company enjoyed throughout the pandemic. While a flatlining of revenue may scare some investors away, there are two good reasons to buy PubMatic stock.

1. An infrastructure cost advantage

PubMatic does not rely on third-party cloud computing services to process the 140 trillion ad impressions its platform handled over the past year. Cloud computing offers a lot of benefits, allowing companies to scale up resources quickly without big capital outlays for servers, networking gear, and other hardware. But that convenience comes at a price.

Instead of turning to the cloud, PubMatic owns and operates its own hardware. This allows the company to tailor its infrastructure to efficiently handle the onslaught of ad impression that runs through its platform. It cost PubMatic $0.54 to process 1 million ad impressions in the third quarter, down 45% from two years ago. As the company further optimizes its hardware and software, it can drive this number even lower as time goes on.

You only have to compare PubMatic's gross margin to that of fellow adtech company Magnite to get a sense of how much of a cost advantage this strategy delivers. PubMatic delivered a GAAP gross margin of 67.8% through the first nine months of 2022, while Magnite managed a gross margin of just 51.2%. In this case, that's the difference between churning out profits and reporting chronic losses.

The downside to running your own infrastructure when demand declines is that hardware utilization can decline as well. The fixed portion of PubMatic's infrastructure expenses won't drop if revenue takes a dive, so the company's gross margin would be adversely affected. PubMatic can slow down its infrastructure expansion and let utilization catch back up, but this is certainly a short-term risk for the company.

2. Profits, cash flow, and a pessimistic valuation

PubMatic stock certainly looks cheap, but profit and free cash flow will likely decline at least somewhat as the company works through a tougher demand environment, so valuation ratios should be used with caution. Still, it's impressive that PubMatic has reached such a high level of profitability with annual revenue expected to be just $260 million this year.

Free cash flow over the past 12 months totaled $50.2 million, putting the price-to-free cash flow ratio at roughly 14. That looks reasonable, although again, free cash flow could very well decline in 2023. The good news is that PubMatic's balance sheet is pristine, with $166 million of cash and marketable securities, and essentially no debt. Even if free cash flow turns negative temporarily, PubMatic can handle it.

PubMatic is also profitable on both a GAAP and non-GAAP basis thanks to the company's frugal spending, both on infrastructure and operating expenses. PubMatic spent just 28% of revenue on sales and marketing expenses through the first nine months of this year, leading to a GAAP operating margin of about 13%.

A long-term buy

In the short term, PubMatic's profit figures are probably going to deteriorate along with demand from advertisers. Infrastructure utilization will be a drag on the gross margin, and the company's 29% increase in headcount over the past two years will weigh on operating costs.

But in the long run, as ad dollars continue to shift to digital channels, PubMatic is in a great position to capture a growing share of that spending. This is still a small company with the potential to grow much faster than the digital advertising market as a whole, and to do so profitably. With a market cap of just $700 million, PubMatic is worth considering for any long-term investor.