Track Instagram and TikTok Follower Counts in Google Sheets Automatically: Apps Script for 9 Networks (2026)
Last updated and prices verified: .
To track Instagram and TikTok follower counts in Google Sheets automatically, stop using IMPORTXML and call a data API from Apps Script. A short script reads each handle in your sheet with UrlFetchApp, writes the followers number next to it and, on a time trigger, appends a dated row to a snapshots tab. With SocialLens the same call, GET https://api.sociallens.dev/v1/profile, covers Instagram, TikTok, YouTube, X, Facebook, Threads, Pinterest and LinkedIn, plus subreddit activity on Reddit. There is no login to any social account, and a new account starts with 250 free reads.
This page covers why the old formulas stopped working, the sheet layout, the complete script, the trigger that builds your history, real responses, the quotas on the Google side, the cost per 1,000 reads next to the alternatives, and when another route is the better one.
Why the Google Sheets Instagram follower count formula is not working
The classic recipe was a formula like =IMPORTXML(A1, "//meta[@name='description']/@content") wrapped in REGEXEXTRACT to pull the number out of the page. It depended on the count being present in the HTML that the server sends. Social networks now build the profile page in the browser with JavaScript and put most of it behind a login wall, and the IMPORT functions of Google Sheets do not run JavaScript or log in. The formula returns #N/A, an empty cell or the wrong number.
The best known guide to those formulas says so itself. The Import Cookbook by Ben Collins now carries an editor's note from 2024 saying that most of its solutions, which are more than four years old, no longer work, and the sections for Instagram, Twitter and LinkedIn each state that the formula stopped extracting followers. TikTok was never covered. That is not a fault of the guide: the pages changed, and no formula can read a number that is not in the HTML.
A custom function such as =FOLLOWERS("instagram", "nasa") is the next idea people try, and it is the wrong tool for this job. Google limits a custom function to 30 seconds per execution, it recalculates when the sheet decides to, and every recalculation would be a new API read. A script that runs from a menu or a trigger and writes plain values is cheaper and predictable.
The sheet: one row per account, one tab for history
Create a spreadsheet with two tabs.
Tab Accounts, with this header in row 1. You fill columns A and B. The script fills C to F.
| network | handle | followers | exact | checked_at | status |
|---|---|---|---|---|---|
| shopify | 2852044 | TRUE | 2026-11-26T00:36:12Z | ok | |
| tiktok | shopify | 2499880 | TRUE | ok | |
| youtube | shopify | 493000 | FALSE | ok | |
| shopify | 1123386 | ok | |||
| threads | shopify | 335933 | TRUE | ok | |
| shopify | 647250 | TRUE | ok |
The counts in this table are real, from reads made on November 25, 2026.
Tab Snapshots, with the header date, network, handle, followers, exact. The script appends one row per account per day here. This tab is your history.
What goes in the network and handle columns:
network value |
What handle takes |
|---|---|
instagram |
The handle, with or without the @ |
tiktok |
The handle |
youtube |
The channel handle, the part after the @ |
x |
The handle |
facebook |
The page handle or the full page URL |
threads |
The handle |
pinterest |
The user handle |
linkedin |
The company slug or the full company URL |
reddit |
A subreddit name. Reddit has no follower count: the script stores weekly active users instead |
Outside LinkedIn and Facebook, send the handle and not a URL. The API answers 400 bad_request to a profile URL on the other networks, which is not charged.
Every endpoint of each network is on its reference page: Instagram API, TikTok API, YouTube API, LinkedIn API, X API, Facebook API, Threads API, Pinterest API and Reddit API. The full network by endpoint table is in the API documentation.
The Apps Script: UrlFetchApp with the key in PropertiesService
- Create a free SocialLens account and copy your API key. No card is asked and the account starts with 250 reads.
- In the spreadsheet, open Extensions > Apps Script.
- Open Project Settings, scroll to Script Properties, and add a property named
SOCIALLENS_KEYwith your key as the value. The key stays out of the code and out of the cells, so sharing the sheet does not share the key. - Replace the content of
Code.gswith the script below and save. - Reload the spreadsheet. A SocialLens menu appears. Choose Update follower counts and authorize the script the first time.
const API = 'https://api.sociallens.dev/v1/profile';
const MAX_RUN_MS = 5 * 60 * 1000; // stop before the 6 minute Apps Script limit
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('SocialLens')
.addItem('Update follower counts', 'updateFollowers')
.addItem('Start daily snapshots', 'createTrigger')
.addToUi();
}
/** One profile read. Retries the three statuses that mean "try again". Errors are not charged. */
function readProfile(platform, username) {
const key = PropertiesService.getScriptProperties().getProperty('SOCIALLENS_KEY');
const url = API + '?platform=' + encodeURIComponent(platform) +
'&username=' + encodeURIComponent(username);
let code = 0;
let data = {};
for (let attempt = 1; attempt <= 3; attempt++) {
const res = UrlFetchApp.fetch(url, {
method: 'get',
headers: { Authorization: 'Bearer ' + key },
muteHttpExceptions: true,
});
code = res.getResponseCode();
try { data = JSON.parse(res.getContentText()); } catch (e) { data = {}; }
if ([409, 429, 503].indexOf(code) === -1) break;
Utilities.sleep(5000);
}
return { code: code, data: data };
}
/** Reads the Accounts tab from the saved position. Returns true when it reached the last row. */
function runBatch() {
const started = Date.now();
const props = PropertiesService.getScriptProperties();
const ss = SpreadsheetApp.getActive();
const accounts = ss.getSheetByName('Accounts');
const snapshots = ss.getSheetByName('Snapshots');
const last = accounts.getLastRow();
if (last < 2) return true;
const today = Utilities.formatDate(new Date(), 'Etc/UTC', 'yyyy-MM-dd');
let row = Number(props.getProperty('NEXT_ROW')) || 2;
if (row > last) row = 2;
for (; row <= last; row++) {
if (Date.now() - started > MAX_RUN_MS) break;
const cells = accounts.getRange(row, 1, 1, 2).getValues()[0];
const platform = String(cells[0]).trim().toLowerCase();
const username = String(cells[1]).trim().replace(/^@/, '');
if (!platform || !username) continue;
const r = readProfile(platform, username);
const d = r.data;
let result;
if (r.code !== 200) {
result = ['', '', '', 'error ' + r.code + (d.error ? ' ' + d.error : '')];
} else if (!d.exists) {
result = ['', '', d.fetched_at, 'not found'];
} else {
// Reddit has no follower count: store the weekly active users of the subreddit.
const raw = platform === 'reddit' ? d.active_users : d.followers;
const count = raw === undefined || raw === null ? '' : raw;
const exact = d.is_exact === undefined ? '' : d.is_exact;
result = [count, exact, d.fetched_at, d.private ? 'private' : 'ok'];
snapshots.appendRow([today, platform, username, count, exact]);
}
accounts.getRange(row, 3, 1, 4).setValues([result]);
}
const finished = row > last;
props.setProperty('NEXT_ROW', finished ? '2' : String(row));
return finished;
}
/** Menu action: read the whole list now, from the first row. */
function updateFollowers() {
PropertiesService.getScriptProperties().deleteProperty('NEXT_ROW');
runBatch();
}
/** Trigger action: one complete pass per UTC day, continued across runs when the list is long. */
function scheduledUpdate() {
const props = PropertiesService.getScriptProperties();
const today = Utilities.formatDate(new Date(), 'Etc/UTC', 'yyyy-MM-dd');
if (props.getProperty('DONE_ON') === today) return;
if (runBatch()) props.setProperty('DONE_ON', today);
}
/** Creates the time trigger. Run it once from the menu. */
function createTrigger() {
ScriptApp.getProjectTriggers().forEach(function (t) {
if (t.getHandlerFunction() === 'scheduledUpdate') ScriptApp.deleteTrigger(t);
});
ScriptApp.newTrigger('scheduledUpdate').timeBased().everyHours(1).create();
}
Three design choices in this script are deliberate:
- One read at a time. SocialLens processes the requests of one account in sequence, and a read takes about 2 to 5 seconds on most networks and 6 or more on Instagram. Do not switch to
UrlFetchApp.fetchAll: parallel calls do not finish sooner and can answer409 account_busy. - It stops before Google stops it. Apps Script ends any execution at 6 minutes. The script checks the clock, saves the row where it stopped in
NEXT_ROWand continues from there on the next run. - Errors never overwrite a good number with a guess. A failed read writes the status and leaves the count empty.
429,409and503are retried and cost nothing.
The daily trigger: how the history gets built
The API returns the count at the moment you ask. It keeps no history, so the series starts on the day your sheet starts recording. That is what the Snapshots tab is for.
Choose SocialLens > Start daily snapshots once. It creates an hourly trigger for scheduledUpdate. The trigger fires every hour, but the reads happen once per UTC day: after a complete pass the function records the date in DONE_ON and the remaining runs of that day exit at once. If the list is too long for one execution, the next hourly run continues where the previous one stopped.
After a week the Snapshots tab looks like a table you can chart or pivot. Two formulas that cover most reports:
One account over time (date and followers):
=QUERY(Snapshots!A:E, "select A, D where B = 'instagram' and C = 'shopify' order by A", 1)
Growth of that account over the last 7 snapshots:
=INDEX(F2:G, COUNTA(F2:F), 2) - INDEX(F2:G, MAX(1, COUNTA(F2:F) - 7), 2)
The second formula assumes the first one sits in F1. Two precision notes for the chart. YouTube publishes subscriber counts rounded to three significant figures, so that line moves in steps and the exact column shows FALSE. On TikTok the profile page shows a rounded figure, and the API returns the exact integer, which is what the script stores.
What the API returns: real responses
This is the request the script sends for one row, written as curl:
curl "https://api.sociallens.dev/v1/profile?platform=instagram&username=shopify" \
-H "Authorization: Bearer sk_live_YOUR_KEY"
The response below is from a read made on November 25, 2026. Timestamps are UTC. These are the main fields: the full response also carries the avatar URL, the account id and a credits object with what the call cost.
{
"exists": true,
"username": "shopify",
"platform": "instagram",
"nickname": "Shopify",
"verified": true,
"private": false,
"followers": 2852044,
"followers_rounded": 2852044,
"is_exact": true,
"following": 1694,
"bio": "The entrepreneurship company",
"external_link": "https://shopify.supply/",
"fetched_at": "2026-11-26T00:36:12Z"
}
LinkedIn answers the same request with a company object. The follower count is in the same place, followers:
{
"exists": true,
"platform": "linkedin",
"type": "company",
"name": "Shopify",
"handle": "shopify",
"followers": 1123386,
"employee_count": 30452,
"location": { "city": "Ottawa", "state": "ON", "country": "CA" },
"website": "https://www.shopify.com",
"fetched_at": "2026-11-26T00:36:16Z"
}
A handle that does not exist answers with exists: false, which the script writes as not found:
{
"exists": false,
"username": "sl_no_such_brand_7q2k9x",
"platform": "tiktok",
"fetched_at": "2026-11-26T00:37:57Z"
}
One company on eight networks, each cell one request, read on November 25, 2026:
| Network | Handle read | followers returned |
is_exact |
|---|---|---|---|
shopify |
2,852,044 | true | |
| TikTok | shopify |
2,499,880 | true |
| YouTube | shopify |
493,000 | false |
| LinkedIn (company) | shopify |
1,123,386 | full number |
| X | Shopify |
457,516 | true |
shopify |
4,563,820 | true | |
| Threads | shopify |
335,933 | true |
shopify |
647,250 | true |
The same read in Python and Node
If you want to test a handle outside the spreadsheet, or backfill a list from your machine, the request is the same.
import os
import requests
API = "https://api.sociallens.dev/v1/profile"
KEY = os.environ["SOCIALLENS_KEY"]
def followers(platform, username):
r = requests.get(
API,
params={"platform": platform, "username": username},
headers={"Authorization": f"Bearer {KEY}"},
timeout=60,
)
r.raise_for_status()
data = r.json()
return data["followers"] if data.get("exists") else None
for platform, username in [("instagram", "shopify"), ("linkedin", "shopify"), ("threads", "shopify")]:
print(platform, username, followers(platform, username))
const API = "https://api.sociallens.dev/v1/profile";
const KEY = process.env.SOCIALLENS_KEY;
async function followers(platform, username) {
const url = `${API}?platform=${platform}&username=${encodeURIComponent(username)}`;
const res = await fetch(url, { headers: { Authorization: `Bearer ${KEY}` } });
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`);
return data.exists ? data.followers : null;
}
// One at a time: reads for the same account are processed in sequence.
for (const [platform, username] of [["instagram", "shopify"], ["tiktok", "shopify"], ["pinterest", "shopify"]]) {
console.log(platform, username, await followers(platform, username));
}
Google Apps Script quotas that matter for a follower tracker
The numbers below are from Google's Apps Script quotas page, read on November 28, 2026.
| Quota | Consumer account (gmail.com) | Google Workspace account |
|---|---|---|
| Script runtime | 6 minutes per execution | 6 minutes per execution |
| URL Fetch calls | 20,000 per day | 100,000 per day |
| Triggers total runtime | 90 minutes per day | 6 hours per day |
| Custom function runtime | 30 seconds per execution | 30 seconds per execution |
What that means in practice:
- One execution reads about 60 to 100 accounts when a read takes 3 to 5 seconds. Instagram reads are slower, from 6 seconds to more than 15, so a list that is mostly Instagram gets through 20 to 50 per execution. Longer lists are continued by the next hourly run, as described above.
- The daily ceiling on a free Google account is trigger runtime, not fetch calls. At about 4 seconds per read, 90 minutes is roughly 1,300 reads a day. That is an estimate from the read times above, not a Google number.
- On the SocialLens side a key allows 60 requests per minute, which a sequential loop never reaches.
Cost per 1,000 reads: SocialLens next to the alternatives
The prices below were read on each vendor's own page on November 28, 2026 and normalized to US dollars per 1,000 reads. One read is one profile checked once.
| Route | Networks in one script | Smallest purchase | Cost per 1,000 reads | Free allowance |
|---|---|---|---|---|
| SocialLens | 9, same request and same followers field |
$19 for 8,000 reads | $2.38 (Starter), $1.98 (Pro, $79 for 40,000), $1.66 (Scale, $299 for 180,000) | 250 reads, one time, no card |
| Scrape Creators | Many, with one endpoint and one response shape per network | $47 for 25,000 credits | $1.88, or $0.99 on the $497 pack of 500,000 | 100 credits |
| SociaVault | Its Sheets tutorials cover Instagram and TikTok | $29 for 6,000 credits | $4.83, $3.95 ($79 for 20,000), $2.65 ($199 for 75,000), $2.00 ($399 for 200,000), at 1 credit per request on most endpoints | 50 credits |
| YouTube Data API | YouTube only | None | $0. The default quota is 10,000 units per day and a channel read costs 1 unit | Not applicable |
| Marketing Data Extractor add-on | Instagram, TikTok and YouTube, no script | See its Marketplace listing | Not published per read | See its listing |
SocialLens is not the lowest line in this table. Scrape Creators costs less per read from its first pack, and for YouTube alone the official API is free. What SocialLens brings to a spreadsheet is one script for every network: the same request and the same followers field on Instagram, TikTok, LinkedIn, Threads, Pinterest, X and Facebook, a $19 entry pack and credits that never expire.
Example: 50 accounts, one snapshot a day. That is about 1,500 reads a month.
| Route | Cost for 1,500 reads | How long the smallest pack lasts |
|---|---|---|
| SocialLens Starter, $19 per 8,000 | $3.56 | A little over 5 months |
| Scrape Creators, $47 per 25,000 | $2.82 | About 16 months |
| SociaVault Starter, $29 per 6,000 | $7.25 | 4 months |
The 250 free reads cover 8 accounts for a month, or 50 accounts for 5 days, which is enough to see the sheet working before paying. Know what counts as a billable read: on SocialLens a 200 response costs 1 credit, including the answers "this profile does not exist" and "this profile is private". Every error status costs nothing. Rates change: confirm them on each pricing page before you budget.
When to use the YouTube API, an add-on or SociaVault instead
- You only track YouTube. Use the official YouTube Data API. It is free inside the daily quota and one channel read costs one unit. You need a Google Cloud project and an API key.
- You only track accounts you own and you want reach, impressions or audience demographics. Those are private metrics. A public data API does not have them. Use each platform's own analytics API or a reporting connector that logs in with your account.
- You do not want to touch a script. An add-on such as Marketing Data Extractor runs inside Google Sheets with no code and no API key, for Instagram, TikTok and YouTube.
- You track only Instagram and TikTok and want post level tabs out of the box. SociaVault publishes ready Instagram and TikTok tutorials for Google Sheets with a posts tab already built.
- Your volume is high and the unit price decides. Scrape Creators is cheaper per read, at the cost of writing one branch per network.
SocialLens also has limits you should know before you start: no history before your first snapshot, no keyword or hashtag search, no audience demographics and no detection of fake followers. It reads the public numbers of a profile you already know.
Frequently asked questions
Why did my IMPORTXML Instagram follower count formula stop working?
Instagram builds the profile page in the browser with JavaScript and shows most of it only to logged in users. IMPORTXML reads the raw HTML from Google's servers, without JavaScript and without a login, so the count is not there to extract. The same happened to the Twitter and LinkedIn formulas.
Can I get LinkedIn and Threads follower counts with Apps Script?
Yes. Put linkedin or threads in the network column and the company slug or handle in the handle column. The script sends the same request and reads the same followers field. LinkedIn also accepts the full company URL.
How often can the sheet update?
As often as you run it. The trigger in this guide records one snapshot per day, which is the right grain for a growth chart. Each update is one read per account, so a shorter interval multiplies the cost and adds little: follower counts of most accounts barely move within an hour.
Do I need to log in to Instagram or TikTok, or connect the accounts?
No. A read needs the public handle and your own SocialLens API key. No social account is connected, and the owner of the profile does not authorize anything. This is also why it works for competitors and clients, not only for accounts you manage.
What does it cost to track 50 accounts every day?
About 1,500 reads a month. On the Starter pack that is $3.56 a month, and one $19 pack lasts a little over 5 months. The first 250 reads are free.
Related guides
- n8n workflow: follower count tracker for 9 networks
- Verify an affiliate applicant's social media followers
- Followers count API for SMM panels
- Enrich a Clay table with follower counts
- Engagement rate API for indie influencer apps
- Data365 and EnsembleData alternatives
- Social media data API for academic research
- Threads API: exact follower count of any account
- Pinterest API: follower count of any profile and saves of a pin