How to Export TikTok Data to Google Sheets (Automatically)
Want to track TikTok creators, analyze competitors, or build an influencer database? Google Sheets is a great place to store and analyze that data.
This tutorial shows you how to automatically pull TikTok data into Google Sheets using SociaVault's social media scraping API.
Need TikTok data access? See our complete TikTok API alternatives guide.
Just getting started? Try free TikTok API options first.
What You'll Build
By the end of this tutorial, you'll have:
- A Google Sheet that tracks TikTok profiles
- Automatic updates of follower counts and engagement
- Historical data for trend analysis
Method 1: Google Apps Script (Free)
The most flexible method uses Google Apps Script - it's free and runs directly in Google Sheets.
Step 1: Create Your Sheet
-
Create a new Google Sheet
-
Set up columns:
- A: Username
- B: Followers
- C: Following
- D: Likes
- E: Videos
- F: Bio
- G: Last Updated
-
Add some TikTok usernames in column A (without @)
Step 2: Open Apps Script
- Go to Extensions → Apps Script
- Delete any existing code
- Paste the following:
const SOCIAVAULT_API_KEY = 'YOUR_API_KEY_HERE';
const API_URL = 'https://api.sociavault.com/tiktok/profile';
function updateTikTokData() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const lastRow = sheet.getLastRow();
// Skip header row, start from row 2
for (let i = 2; i <= lastRow; i++) {
const username = sheet.getRange(i, 1).getValue();
if (!username) continue;
try {
const data = fetchTikTokProfile(username);
if (data && !data.error) {
sheet.getRange(i, 2).setValue(data.followers || 0);
sheet.getRange(i, 3).setValue(data.following || 0);
sheet.getRange(i, 4).setValue(data.likes || 0);
sheet.getRange(i, 5).setValue(data.videos || 0);
sheet.getRange(i, 6).setValue(data.bio || '');
sheet.getRange(i, 7).setValue(new Date());
}
// Rate limiting - wait 1 second between requests
Utilities.sleep(1000);
} catch (error) {
console.log('Error for ' + username + ': ' + error);
}
}
}
function fetchTikTokProfile(username) {
const options = {
method: 'post',
contentType: 'application/json',
headers: {
'Authorization': 'Bearer ' + SOCIAVAULT_API_KEY
},
payload: JSON.stringify({ username: username }),
muteHttpExceptions: true
};
const response = UrlFetchApp.fetch(API_URL, options);
return JSON.parse(response.getContentText());
}
// Add menu item to run manually
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('TikTok Data')
.addItem('Update All Profiles', 'updateTikTokData')
.addToUi();
}
Step 3: Add Your API Key
- Replace
YOUR_API_KEY_HEREwith your SociaVault API key - Click Save (disk icon)
Step 4: Run the Script
- Click Run → updateTikTokData
- Authorize the script when prompted
- Watch your sheet populate with TikTok data!
Step 5: Automate with Triggers
- Click Triggers (clock icon in left sidebar)
- Click Add Trigger
- Configure:
- Function:
updateTikTokData - Event source: Time-driven
- Type: Day timer
- Time: Select when to run
- Function:
Now your sheet updates automatically every day!
Method 2: Using Zapier (No Code)
If you prefer a no-code solution:
- Create a Zap: Schedule → Webhooks → Google Sheets
- Schedule trigger: Daily
- Webhooks action: POST to
https://api.sociavault.com/tiktok/profile - Google Sheets action: Update row
See our Zapier integration guide for details.
Method 3: Python Script
For more control, use Python:
import gspread
import requests
from oauth2client.service_account import ServiceAccountCredentials
# SociaVault setup
API_KEY = 'YOUR_API_KEY'
API_URL = 'https://api.sociavault.com/tiktok/profile'
# Google Sheets setup
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
client = gspread.authorize(creds)
sheet = client.open('TikTok Tracker').sheet1
def get_tiktok_data(username):
response = requests.post(
API_URL,
headers={'Authorization': f'Bearer {API_KEY}'},
json={'username': username}
)
return response.json()
def update_sheet():
usernames = sheet.col_values(1)[1:] # Skip header
for i, username in enumerate(usernames, start=2):
data = get_tiktok_data(username)
if not data.get('error'):
sheet.update(f'B{i}:G{i}', [[
data.get('followers', 0),
data.get('following', 0),
data.get('likes', 0),
data.get('videos', 0),
data.get('bio', ''),
str(datetime.now())
]])
if __name__ == '__main__':
update_sheet()
Tracking More Data
Add Video Data
Extend the script to track recent videos:
function fetchRecentVideos(username) {
const options = {
method: 'post',
contentType: 'application/json',
headers: {
'Authorization': 'Bearer ' + SOCIAVAULT_API_KEY
},
payload: JSON.stringify({ username: username, count: 10 }),
muteHttpExceptions: true
};
const response = UrlFetchApp.fetch(
'https://api.sociavault.com/tiktok/videos',
options
);
return JSON.parse(response.getContentText());
}
Calculate Engagement Rate
Add a formula in Google Sheets:
=((B2*0.05 + D2) / B2) * 100
This estimates engagement based on followers and likes.
Tips for Large Datasets
Batching
Process usernames in batches to avoid timeouts:
function updateBatch(startRow, batchSize) {
// Process only a subset of rows
for (let i = startRow; i < startRow + batchSize; i++) {
// ... update logic
}
}
Caching
Don't update profiles that were updated recently:
const lastUpdated = sheet.getRange(i, 7).getValue();
const hoursSinceUpdate = (new Date() - new Date(lastUpdated)) / (1000 * 60 * 60);
if (hoursSinceUpdate < 24) {
continue; // Skip if updated within 24 hours
}
Common Issues
"Exceeded maximum execution time"
- Break your script into batches
- Use triggers to run multiple times
"Service invoked too many times"
- Add
Utilities.sleep(1000)between API calls - Reduce trigger frequency
Empty data returned
- Verify the username exists
- Check if the account is private
Cost Calculation
Each profile update = 1 SociaVault credit
- 100 profiles daily = 100 credits/day = 3,000 credits/month
- Growth pack (20,000 credits) = ~6 months of tracking
Next Steps
- Get your SociaVault API key (50 free credits)
- Copy the script above into your Google Sheet
- Add your TikTok usernames and run!
Need more data? SociaVault also supports Instagram, YouTube, Twitter, LinkedIn, and 20+ more platforms. Same API, same process!
Related Articles
Found this helpful?
Share it with others who might benefit
Ready to Try SociaVault?
Start extracting social media data with our powerful API. No credit card required.