Facebook’s plot for ad domination is coming to fruition. Today at Facebook headquarters, its ad execs explained how two years of seemingly isolated launches and acquisitions are melding into a powerful way to show ads across the Internet and track the purchases they inspire both online and offline.

Here’s how the pieces come together:

Facebook brings its 1.35 billion users and massive engagement with the News Feed where it shows its ads. Because its huge user base stays logged in across web and mobile, it has a unified understanding of people’s identities in a way most platforms don’t. Facebook’s wealth of personal data means it can target ads more accurately. For instance, it says it can target gender with 90 percent accuracy compared to the online ad industry average of 50 percent.

Tracking online purchases inspired by its ad clicks is easy, but what’s more difficult is understanding offline purchase behavior.

How Facebook Custom Audiences works

So Facebook built what’s called Custom Audiences, which lets businesses upload their purchase data and identifying information about their customers to Facebook in a hashed, privacy-protected way. Facebook can both use this to let businesses target ads to their existing customers, but also to reference them against who saw ads to prove that impressions on web or mobile, even without clicks, lead to purchases.

Facebook also collects offline purchase data tied to people’s grocery loyalty cards and other identifiers through partners like Datalogix. The point of all this measurement is that when advertisers can see they’re getting a return on investment, they spend more.

This all worked great on Facebook, but the company saw a huge opportunity to bring this to the rest of the web. So in February 2013, Facebook acquired Microsoft’s Atlas, a suite of tools for online ad measurement. This let Facebook bring its understanding of cross-device ROI to ads across the web run through Atlas.

As for publishers, the websites and apps that host ads, Facebook saw video content becoming more popular. Many publishers were working with a video adtech platform called LiveRail that connects them to video advertisers and targets the little commercials. So Facebook acquired LiveRail for around $500 million in July 2014.

Meanwhile, Facebook had built and launched Audience Network, a mobile ad network that lets advertisers easily extend their Facebook ad campaigns to appear in other mobile apps. This gave Facebook the connective tissue to tie the other pieces together.

Advertisers on Atlas can easily buy ads on Facebook or use Audience Network to extend their campaigns to LiveRail and mobile apps.

The subtext of today’s session was that Facebook thinks it’s ready to soak up the flood of ad dollars starting to slosh off of television and into digital. Facebook will have to battle Google and YouTube, Yahoo, AOL (TechCrunch’s parent company), and Twitter for that ad spend. Atlas’ David Jakubowski says “We know Google’s working pretty hard on this exact thing [cross-device, online/offline measurement]. We expect they’ll do something in this space.”

But if the social network can prove its scale, targeting, and measurement surpass its competitors, Madison Avenue might agree that Facebook is the successor to TV.