keepcalculator

06 Numbers and Powers

Local Pack Rankings: Scheduled Screenshots Guide

Card No. 06·51096 · Updated · Standard formula, shown below

This guide shows you how to automatically capture screenshots of your local pack rankings (the map-and-list block that appears for local searches) on a schedule. You’ll set up a free or low-cost system that takes a snapshot of your Google Maps rankings at set times, so you can track changes over days, weeks, or months without manually checking. You’ll need a Google account, a spreadsheet or text file to store the URLs you want to track, and access to a scheduling tool (like Google Sheets with Apps Script, or a free cron service).

What You’ll Need

  • A Google account (for Google Sheets and Apps Script, or to use Google Alerts as a trigger)
  • The exact search queries and locations you want to track (e.g., “plumber near me” + “Austin, TX”)
  • A list of the businesses or places you want to monitor (your own or competitors)
  • A free or low-cost screenshot API or service (e.g., ScreenshotOne, Urlbox, or a free tier of a similar tool)
  • Basic familiarity with Google Sheets and Apps Script (or a willingness to copy-paste a script)

Step-by-Step

  1. Set up your tracking spreadsheet. Open Google Sheets and create a new spreadsheet. In the first row, add headers: “Search Query”, “Location”, “Business Name”, “Screenshot URL”. In the rows below, enter each search you want to track. For example, row 2 might be: “plumber near me”, “Austin, TX”, “My Business”, “”.
  2. Generate a screenshot API key. Sign up for a screenshot service that offers a free tier (like ScreenshotOne or Urlbox). Get your API key and note your base URL (e.g., https://api.screenshotone.com/take). You’ll use this to create a screenshot URL for each search.
  3. Build the screenshot URL for each row. In column D (Screenshot URL), enter a formula that constructs the API call. For ScreenshotOne, it might look like: =CONCATENATE("https://api.screenshotone.com/take?url=", ENCODEURL("https://www.google.com/maps/search/" & A2 & "+in+" & B2), "&access_key=YOUR_API_KEY&format=png&width=1200&height=800"). Replace YOUR_API_KEY with your actual key. This URL will, when clicked or fetched, take a screenshot of the Google Maps search results for that query.
  4. Write the Apps Script to fetch screenshots. In Google Sheets, go to Extensions > Apps Script. Delete any code and paste the following script (adjust the sheet name if needed):
    function captureScreenshots() {
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
      var lastRow = sheet.getLastRow();
      for (var i = 2; i <= lastRow; i++) {
        var url = sheet.getRange(i, 4).getValue(); // Column D
        if (url) {
          var response = UrlFetchApp.fetch(url, {muteHttpExceptions: true});
          var blob = response.getBlob();
          var folder = DriveApp.getFolderById("YOUR_FOLDER_ID"); // Replace with your Google Drive folder ID
          var filename = "rank_" + i + "_" + new Date().toISOString() + ".png";
          folder.createFile(blob).setName(filename);
          sheet.getRange(i, 5).setValue("Captured at " + new Date()); // Column E for status
        }
      }
    }
        

    Replace YOUR_FOLDER_ID with the ID of a folder in your Google Drive where you want the screenshots saved. Save the script.

  5. Set a trigger to run the script automatically. In the Apps Script editor, click the clock icon (Triggers). Click "Add Trigger". Choose the function captureScreenshots, select "Time-driven", then choose how often (e.g., "Day timer" and pick a time). Save the trigger. The script will now run automatically at that interval.
  6. Test the system manually. Before relying on the trigger, run the script once by clicking the play button in Apps Script. Authorize the script to access your Sheets, Drive, and external URLs. Check your Drive folder for the first screenshots.
  7. Review the screenshots. Open a few screenshots to confirm they show the local pack (the map and list of businesses). If they don't, adjust the URL formula (e.g., add &hl=en for English, or &gl=us for country).
  8. Schedule additional times if needed. You can add multiple triggers (e.g., morning and evening) to capture daily changes. Just add another trigger with a different time.

Common Mistakes

  • Not encoding the query. If you leave spaces or special characters in the URL, the API may return an error. Always use ENCODEURL() in the formula.
  • Using the wrong folder ID. The script will fail if the folder ID is incorrect. Copy the folder ID from the URL when you open the folder in Drive (the long string after /folders/).
  • Forgetting to authorize the script. The first run will ask for permissions. If you skip it, the trigger will fail silently. Always run the script manually once to authorize.
  • Not checking the screenshots for quality. Sometimes the screenshot may capture a cookie consent page or a blank map. Test multiple times and adjust the URL parameters (e.g., add &delay=5 to wait for page load).
  • Overloading the free tier. If you track many queries and run frequently, you may hit the API's monthly limit. Monitor your usage and upgrade if needed.

Tips

  • Use consistent search terms. Local pack rankings vary by device, location, and personalization. To get comparable screenshots, always use the same query and location, and consider adding &gl=us&hl=en to your URL to standardize the country and language.
  • Store screenshots in a dated folder. Instead of dumping all screenshots in one folder, create a subfolder for each day or week. You can modify the script to create a new folder for each run using DriveApp.createFolder().
  • Add a status column. The script writes "Captured at ..." in column E. This helps you quickly see which runs succeeded and which failed.
  • Combine with a spreadsheet of rankings. If you also manually note the top 3 businesses each week, you can correlate with your screenshots for deeper analysis.
  • Use a dedicated Google account. To avoid cluttering your personal Drive, create a separate Google account for this tracking project.

Troubleshooting

  • Screenshots are blank or show a login page. Google may show a consent page for new cookies. Add &delay=5 or &wait_until=network_idle to your API URL to give the page time to load. Also try adding &full_page=true if you need the full page.
  • Script returns an error like "Exception: Invalid argument". Check that the URL in column D is a valid, full URL (starts with https://). Also ensure the folder ID is correct and the folder exists.
  • Trigger runs but no screenshots appear. Check the Apps Script execution log (View > Logs) for errors. Common issues: quota exceeded, or the API key is invalid. Also confirm that the script is writing to the correct sheet (Sheet1) and that column D has values.
  • Screenshots are too small or cropped. Adjust the width and height parameters in the URL formula. For local pack, a width of 1200 and height of 800 usually works. If you need the full page, add &full_page=true.
  • The API returns a 402 error. You've likely exceeded your monthly free quota. Wait for the next month or upgrade your plan.

Frequently Asked Questions

Can I do this without a screenshot API?

Yes, you can use Google's own URL to PDF feature in Chrome (Ctrl+P) but it's manual. A screenshot API automates it. There are free tiers, but they have limits.

Will this work for any search engine?

This guide focuses on Google Maps local pack. For Bing or Yahoo, you'd need to adjust the search URL, but the principle is the same.

How often should I schedule screenshots?

It depends on how volatile your rankings are. Daily is common, but for fast-moving niches, you might want every 6 hours. For stable rankings, weekly is enough.

Can I track multiple businesses at once?

Yes, just add more rows to your spreadsheet. Each row will generate a screenshot. Just be mindful of API limits.

Do I need to keep the screenshots forever?

No, you can delete old ones after you've analyzed them. But keeping a few months of history can help spot trends.

What if the local pack doesn't appear in the screenshot?

Sometimes Google shows a different layout (e.g., a map with a sidebar). Try adding &tbm=map or &tbm=lcl to the URL to force the local pack view.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →