One of the biggest trends available to investors today is the shift from traditional advertising to digital advertising. The shift has been happening for years now, but it still has plenty of runway.

According to data from Statista, the global digital-ad market is expected to grow almost 9% this year with nearly 7% compound annual growth thereafter through 2028. That would put the market size at close to $1 trillion.

Advertising for connected TV (CTV) is one of the hotter growth trends inside of digital advertising. According to third-party research group GroupM, CTV advertising spending is expected to grow at over a 10% compound annual rate from 2023 through 2028.

Given the research, it's prudent to invest in digital advertising and to invest specifically in advertising for CTV. This might be why investors have been so successful with shares of market darling The Trade Desk (TTD 1.67%).

Since going public in 2016, trailing 12-month revenue for The Trade Desk is up more than 1,200%. This performance for the stock is both a reflection of the growth in the industry as well the company's ability to take market share in the CTV advertising space. Investors have been rewarded as well. Even just a $1,000 investment in The Trade Desk when it went public would be worth about $26,000 now.

TTD Chart

TTD data by YCharts.

As great as The Trade Desk is and as bright as its future, the stock is quite expensive, which gives some investors pause. But fortunately, there's a lesser-known company that stands to benefit from the same trends. It's financially sound and well positioned for the future. And importantly, it trades at a much better bargain valuation.

A small-cap contender in CTV

On one side of digital advertising you have The Trade Desk, which partners with advertisers to get ads placed with publishers. On the other side, you have PubMatic (PUBM 1.75%), which partners with publishers to fill their ad slots. And more publishers want to work with PubMatic.

At the end of 2023, PubMatic was working with around 1,800 publishers compared to just 1,650 at the end of 2022. Within this number, it grew its CTV publisher customers by 37% year over year.

Growth in its customer base is leading to an increase in ad impressions for PubMatic (the amount of times an ad is displayed). The company processed over 59 trillion ad impressions in the fourth quarter of 2023, which was up 23% from the prior-year period. CTV ad impressions were up 39% in 2023 compared to 2022.

PubMatic admittedly is in a more vulnerable position in the advertising technology (adtech) space compared with The Trade Desk. It may be easier for large publishers to bring ad technology in-house. However, PubMatic makes up for its vulnerability by fortifying its business in multiple ways.

For starters, PubMatic owns its infrastructure, unlike other players that outsource infrastructure to cloud providers. This gives the company a greater degree of cost control as it grows, whereas others have more variable costs. For example, its ad impressions in 2023 were up 32% year over year, but its cost per thousand ad impressions decreased by 8%.

Additionally, PubMatic positioned its business by fortifying its financial position. The company already generates positive free cash flow, so it's moving forward, not back. And it has a debt-free balance sheet and $175 million in cash, cash equivalents, and investments.

As a small-cap stock with a market cap of just $1 billion, PubMatic is in a rock-solid position.

If someone wanted to invest in digital advertising generally or invest in CTV specifically, The Trade Desk stock would be a good option. I've already pointed out how well it's doing. However, PubMatic is in good shape as well. And of the two, PubMatic stock is the better bargain, and it's not even close.

On a price-to-sales basis, The Trade Desk stock is almost five times more expensive than PubMatic stock. However, some might argue that the businesses are different enough that they shouldn't be compared on a sales basis.

Very well. On a free-cash-flow basis, The Trade Desk stock is still more than three times as expensive, as seen below.

TTD Price to Free Cash Flow Chart

TTD Price to Free Cash Flow data by YCharts.

I'm not necessarily saying that investors shouldn't buy The Trade Desk stock. But PubMatic is exposed to the same trends and is also a good option for investors looking for long-term upside.

The difference between the two is that PubMatic stock is actually a good deal, whereas The Trade Desk stock is expensive. This is why I believe PubMatic is the better buy of the two today.