Scraping Meta Business Manager: Quick Extraction of Useful Data

Sometimes, you need to quickly copy details from the Meta Business Manager to share via email or chat, or to include in a report or presentation—be it a list of ad accounts, pages, pixels, custom conversions, and more. Unfortunately, some of these elements aren’t as straightforward to copy and share since they’re not exportable/downloadable directly through the Meta BM interface.

Often, the best you can do is copy from the screen, which means dealing with awkward formatting, styles, and additional columns and data that tag along unnecessarily.

But what if you could bypass this by scraping the UI to obtain clean, spreadsheet-ready data with just a few clicks? Below are several copy-paste scripts designed to help you extract data from all the useful sections of the Meta interface efficiently.

Just copy, paste and run the script in the Console of your browser dev tools to get a JSON of the data. Then copy the JSON and convert it to a spreadsheet format using a free tool like this one: JSON to CSV converter  

Copy Anything from The Overview Tab 

The following script will help you copy lists of assets from any section of the Overview tab of the Business Manager.   
 

Overview Tab > Users

Partners

  • System Users
 

Overview Tab > Accounts Section

  • Pages
  • Ad Accounts
  • Instagram Accounts
  • Commerce Accounts
  • WhatsApp Accounts
 

Overview Tab > Data Sources:

  • Catalogs
  • Pixels
  • Offline Events
  • Datasets
  • Custom Conversions
  • Event source groups
  • Shared audiences
  • Business creative folders
 

Overview Tab > Brand Safety and Suitability

  • Domains
  • Block lists
  • Publisher allow lists
 

Overview Tab > Registration

  • New Pages
 

Overview Tab > Integrations

  • Connected Apps
  • Lead Access
 
				
					(function() {
    // Define an array to hold all your items
    let items = [];

    // Query all the containers of the items you're interested in. Adjust the selector as needed.
    const containers = document.querySelectorAll('._25b6._21op._2pi9._3qn7._61-3._2fyi._3qng');

    // Iterate over each container to extract the information
    containers.forEach(container => {
        // Extract the page name, status, and notes
        let pageName = container.querySelector('div.ellipsis:first-child')?.innerText.trim();
        let status = container.querySelector('div.ellipsis:nth-child(2)')?.innerText.trim();
        let notes = container.querySelector('div.ellipsis:nth-child(3)')?.innerText.trim(); // This will get an empty string if the div is empty, as shown in your HTML

        // Create an object for the current item and push it into the items array
        items.push({
            PageName: pageName || "N/A", // Fallback to "N/A" if undefined
            Status: status || "N/A",
            Notes: notes || "N/A"
        });
    });

    // Log the JSON string to the console
    console.log(JSON.stringify(items, null, 2));

    // Optionally, if you want to use this JSON in another application, you could return it here
    return items;
})();
(function() {
    // Define an array to hold all your items
    let items = [];

    // Query all the containers of the items you're interested in. Adjust the selector as needed.
    const containers = document.querySelectorAll('._25b6._21op._2pi9._3qn7._61-3._2fyi._3qng');

    // Iterate over each container to extract the information
    containers.forEach(container => {
        // Extract the page name, status, and notes
        let pageName = container.querySelector('div.ellipsis:first-child')?.innerText.trim();
        let status = container.querySelector('div.ellipsis:nth-child(2)')?.innerText.trim();
        let notes = container.querySelector('div.ellipsis:nth-child(3)')?.innerText.trim(); // This will get an empty string if the div is empty, as shown in your HTML

        // Create an object for the current item and push it into the items array
        items.push({
            PageName: pageName || "N/A", // Fallback to "N/A" if undefined
            Status: status || "N/A",
            Notes: notes || "N/A"
        });
    });

    // Log the JSON string to the console
    console.log(JSON.stringify(items, null, 2));


})();

				
			

Copy The List of Audiences from The Audiences Section

This script copies the table of Audiences from the Business Manager’s Audiences section. It’s useful for analyzing audience parameters outside the Business Manager or including them in a report or email.

				
					function extractDataFromRows() {
    const dataRows = document.querySelectorAll('._1gda._2djg'); // selector for the rows
    const extractedData = Array.from(dataRows).map(row => {
        // extract fields
        const name = row.querySelector('div[datakey="name"] a') ? .textContent.trim() || 'Not Found';
        const type = row.querySelector('div[datakey="type"] .x8t9es0.x1fvot60.xo1l8bm.xxio538.x108nfp6.xuxw1ft.x6ikm8r.x10wlt62.xlyipyv.x1h4wwuj.xeuugli') ? .textContent.trim() || 'Not Found';
        const size = row.querySelector('div[datakey="size"] .x8t9es0.x1fvot60.xo1l8bm.xxio538.x108nfp6.xq9mrsl.x1h4wwuj.xeuugli') ? .textContent.trim() || 'Not Found';
        const status = row.querySelector('div[datakey="status"] .x8t9es0.x1fvot60.xo1l8bm.xxio538.x108nfp6.xq9mrsl.x1h4wwuj.xeuugli') ? .textContent.trim() || 'Not Found';
        const dateCreated = row.querySelector('div[datakey="date_created"] .x8t9es0.x1fvot60.xo1l8bm.xxio538.x108nfp6.xq9mrsl.x1h4wwuj.xeuugli') ? .textContent.trim() || 'Not Found';

        return { Name: name, Type: type, Size: size, Status: status, 'Date Created': dateCreated };
    });


    console.log(extractedData);
    
}

extractDataFromRows();
				
			

Copy The List of Custom Conversions from Events Manager

This script will help you copy all your custom conversions for all of your Meta pixels into a neat spreadsheet format, making it easier to share in reports or meetings if you have a lot of custom conversions.

				
					function extractCustomConversions() {
    const conversions = new Map();
    
    const rows = document.querySelectorAll('div[role="listitem"]');
    
    rows.forEach(row => {
        const nameElement = row.querySelector('.ellipsis');
        const idElement = row.querySelector('.ellipsis + div > .ellipsis');
        const statusElement = row.querySelector('._3-8_ + div');
        const pixelElement = row.querySelector('a.xt0psk2');
        const pixelIdElement = row.querySelector('span[value]');
        const conversionsElement = row.querySelector('span.x8t9es0.x1fvot60.xo1l8bm.xxio538.x108nfp6.xq9mrsl.x1h4wwuj.xeuugli');
        const lastReceivedElement = row.querySelector('.x8t9es0.xw23nyj.xo1l8bm.x63nzvj.x6lvj10.xuxw1ft.x6ikm8r.x10wlt62.xlyipyv.x1h4wwuj.xeuugli');
        
        const conversionItem = {
            Name: nameElement ? nameElement.textContent.trim() : 'Not Found',
            ID: idElement ? idElement.textContent.trim() : 'Not Found',
            Status: statusElement ? statusElement.textContent.trim() : 'Not Found',
            Pixel: pixelElement ? pixelElement.textContent.trim() : 'Not Found',
            PixelID: pixelIdElement ? pixelIdElement.getAttribute('value') : 'Not Found',
            Conversions: conversionsElement ? conversionsElement.textContent.trim() : 'Not Found',
            LastReceived: lastReceivedElement ? lastReceivedElement.textContent.trim() : 'Not Found'
        };

        // Use ID as a unique key to prevent duplicates
        conversions.set(conversionItem.ID, conversionItem);
    });
    
    // Convert the map values to an array
    return Array.from(conversions.values());
}

console.log(extractCustomConversions());

				
			

Most of the other data within Business Manager can be exported to CSV through its native export feature and doesn’t require scraping. So, go ahead and give it a try! Happy scraping!

Leave a Reply

Your email address will not be published. Required fields are marked *

Other Posts

Time on Site or Visit Duration Custom Trigger in GTM

Imagine you need to segment your users by their visit duration and break them down into groups like 3, 5, 10 minute visits. Such segmentation can help you enhance your marketing tactics, target your most engaged and interested users with custom messages and ads, remarket to them on social media…

Scraping Meta Business Manager: Quick Extraction of Useful Data

Sometimes, you need to quickly copy details from the Meta Business Manager to share via email or chat, or to include in a report or presentation—be it a list of ad accounts, pages, pixels, custom conversions, and more. Unfortunately, some of these elements aren’t as straightforward to copy and share…

Looker Studio Custom Channel Groupings

Google’s default channel groupings are notorious for misattributing traffic. More often than not, they assign it to the wrong channels or relegate it to the “Unassigned” category. This issue becomes even more pronounced in larger projects that utilize custom source/medium tags (UTM tags) without standardized naming conventions. It’s particularly challenging…