Problem

Identifying marketing professionals from target companies was eating up my team’s time and energy. Manually using LinkedIn & Apollo was one way to go about it, but it wasn’t scalable.

Solution

Automating the process – I built a Google Apps Script that takes in a list of company domains, hits the Apollo API, and populates a google sheet with the names, titles, and LinkedIn profiles of marketing folks from those companies.

Implementation

  1. Used Apollo’s /mixed_people/search endpoint to filter people by:

    • Titles: Marketing, SEO, Content

    • Company domain: dynamically pulled from Sheet1

  2. Parsed the JSON response to extract:

    • Name

    • Job Title

    • LinkedIn URL

  3. Wrote the data into Sheet2 using SpreadsheetApp.

  4. Added error handling + 1-second delay to respect API rate limits.

function enrichDataFromApollo() {
const apiKey = ‘APOLLO_API_KEY’;

const sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Sheet1”);
const sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Sheet2”);

const range = sheet1.getRange(2, 1, sheet1.getLastRow() – 1, 1);
const domains = range.getValues();

sheet2.clearContents();
sheet2.getRange(1, 1).setValue(“Domain”);
sheet2.getRange(1, 2).setValue(“Name”);
sheet2.getRange(1, 3).setValue(“Title”);
sheet2.getRange(1, 4).setValue(“LinkedIn URL”);

let rowIndex = 2;

for (let i = 0; i < domains.length; i++) { const domain = domains[i][0];
if (!domain) continue;
// Construct the URL with domain as query parameter const apiUrl = ‘https://api.apollo.io/api/v1/mixed_people/search?’ + ‘person_titles[]=SEO&’ + ‘person_titles[]=Content&’ + ‘person_titles[]=Marketing&’ + ‘q_organization_domains_list[]=’ + encodeURIComponent(domain) + ‘&’ + ‘per_page=15’; // Set the options for the API request const options = { ‘method’: ‘get’, // Using GET method since domain is part of query ‘headers’: { ‘Cache-Control’: ‘no-cache’, ‘Content-Type’: ‘application/json’, ‘accept’: ‘application/json’, ‘x-api-key’: apiKey } }; try { // Make the API request and get the response const response = UrlFetchApp.fetch(apiUrl, options); const responseJson = JSON.parse(response.getContentText()); // Only process the ‘people’ array, limit to the first 8 records if (responseJson.people && responseJson.people.length > 0) {

for (let j = 0; j < responseJson.people.length; j++) {
const person = responseJson.people[j];
sheet2.getRange(rowIndex, 1).setValue(domain);
sheet2.getRange(rowIndex, 2).setValue(person.name);
sheet2.getRange(rowIndex, 3).setValue(person.title);
sheet2.getRange(rowIndex, 4).setValue(person.linkedin_url);
rowIndex++;
}
} else {
sheet2.getRange(rowIndex, 1).setValue(domain);
sheet2.getRange(rowIndex, 2).setValue(‘No data found’);
rowIndex++;
}
} catch (error) {

Logger.log(‘Error fetching data for domain: ‘ + domain + ‘, Error: ‘ + error);
sheet2.getRange(rowIndex, 1).setValue(domain);
sheet2.getRange(rowIndex, 2).setValue(‘Error fetching data’);
rowIndex++;
}

Utilities.sleep(1000);
}
}

Results

  • ⚡ Cut down lead sourcing time by 90%

  • 🧠 Got enriched data for 15 domains in under a minute

  • 🔗 Easily plugged into outreach workflows

View other case studies