Could billions of dollars’ worth of digital advertising budgets hinge on a few lines of code?

It sounds dramatic. However, the way Facebook and Google implement tracking code from third-party measurement companies is at the heart of lingering tensions between ad buyers and the giants of the digital ad business.

Ad buyers want more transparency into how third-party data is collected on Facebook and Google’s YouTube, and ideally more oversight over the process since it helps them determine where and how to spend their video marketing money. Meanwhile, Facebook and Google—which reeled in 68% of spending on U.S. online advertising in the second quarter, according to Pivotal Research—argue that they provide and allow for plenty of measurement, just with some restrictions to protect users’ privacy and to keep pages loading quickly.

It is common practice in digital campaigns for ad buyers to send publishers what are known as “tags,” which are lines of code that enable them to track the performance of ad campaigns, like how many times an ad is delivered and whether people click on it. In recent years, concerns have risen about whether digital ads can actually be seen on various screens, so ad buyers have also taken to bundling in additional code to track viewability.

However, Facebook and YouTube have never allowed agencies to use their own tags or to collect their own viewability data on web video campaigns. Advertisers can send Facebook and YouTube tiny pieces of code that allow for some basic data on impressions (which can’t be used for billing purposes). But for data on viewability, time spent and more sophisticated metrics, buyers have to rely on YouTube’s and Facebook’s custom integrations with third-party partners like Moat and Integral Ad Science, known as IAS.

Photo: iStock Photo

There’s the rub. Some ad buyers allege that the way that viewability tracking firms measure data on Facebook and YouTube is fundamentally different from how the process works with the average web publisher. They grumble that, in particular, Facebook—even as it has touted its willingness to work with numerous third-party metrics firms following its recent video overcounting mess—doesn’t always provide straight answers regarding how these integrations work.

Ad buyers want to understand who is actually collecting the raw data—the third parties or Facebook itself.

“We believe objective, third-party measurement is an essential foundation for any mature industry,” said Lyle Schwarz, director of implementation, research and marketplace analysis at the ad buying giant GroupM. “It is key that qualified vendors such as Moat, DoubleVerify, Integral Ad Science or others involved with a publisher be able to measure for themselves, not just evaluate measurement provided by the publisher.”

Most web publishers implement code from companies like Moat or IAS using what’s called a “software development kit,” or SDK, which enables these third parties to collect data directly.

Facebook and YouTube do things a bit differently. Instead of allowing third parties to directly pull data from their sites or mobile apps, Facebook and YouTube receive tracking code from the third parties and then modify the code slightly. They also set up a different process to deliver data than is used via typical SDK partnerships.

Facebook and Google say there are good reasons for their approach. (For a primer on how Facebook’s third-party metrics work, click here). Simply copying and pasting code from third parties into their mobile apps could negatively impact the user experience by slowing down the loading of pages, they contend.

More important, each company is hesitant to let third parties see too much, since both Facebook and Google have reams of consumer data that is vital to their businesses and could set off numerous privacy alarms if exposed. They aren’t alone in their hesitation. Snapchat is also not planning to allow any third-party code directly on its app, according to a person familiar with the matter.

For its part, Facebook says that while the process may be different, the net result is that the data received is “identical to any other integration style,” according to Mark Rabkin, vice president of Facebook’s core ads team. “The data takes a different train to the same destination.”

“We’re really, really committed to advertiser value in everything we do,” Mr. Rabkin added. “We want to make them feel really comfortable.”

But the different methodology—particularly the involvement of Facebook and YouTube in setting up the data collection process—has left the advertising world with a sense that their third-party tracking isn’t fully third party.

Photo: Shutterstock.com

They are “still not technically being independently third party measured,” said Mitchell Weinstein, senior vice president of ad operations at the media buying firm IPG Mediabrands. Tal Chalozin, co-founder at ad tech company Innovid, agrees, adding that “the publisher needs to be completely disconnected” for there to be unbiased measurement.

Moat Chief Executive Jonah Goodhart argues that while his company’s work with Facebook and YouTube is unique, it’s still completely objective. He’s adamant that Moat’s data on Facebook and YouTube is solid and just as robust as any other partner, yielding more than 60 different metrics. For example, with Facebook, Moat has two full-time employees focusing on gauging whether its data collection is accurate via an extensive set of testing using a set of Facebook test accounts—without Facebook’s involvement.

“We are completely confident in the approach we take,” Mr. Goodhart said.

Some in the industry wonder whether this battle is less about the technicalities of measurement and more about fears of Facebook’s and Google’s increasing hold on the digital ad market.

It’s potentially in ad buyers’ interests to loudly complain about measurement to gain leverage in negotiations. For instance, many in the ad world were up in arms over Facebook’s recent miscalculation that overestimated for two years the average time users spent watching videos, even though the metric had no impact on billing. (Facebook apologized for the miscalculation.)

Facebook says it goes to great lengths to provide transparency into its practices.

“We meet weekly with top questions and clients where we have open conversations about these issues,” said Facebook’s Mr. Rabkin. “We try to do our absolute best.”

Write to Mike Shields at mike.shields@wsj.com