Skip to content

Instantly share code, notes, and snippets.

@nickboyce
nickboyce / instagram_count_to_googe_sheet.js
Last active June 23, 2024 22:01
Track your Instagram followers over time with Google Sheets Scripts
// Thank you to @juliendev for his script (updated here with minor cosmetic changes)
// https://gist.github.com/JulienDev/df5a3b66e899c224fa1b2dc90acfa2ae
// Your sheet name in the document
var sheetName = "Sheet1";
// Your instagram user id
var user_id = ""; //find your id here : https://codeofaninja.com/tools/find-instagram-user-id
var instagram_base_url = "https://www.instagram.com/graphql/query/";
var following = "?query_hash=58712303d941c6855d4e888c5f0cd22f&variables=%7B%22id%22%3A%22" + user_id + "%22%2C%22first%22%3A24%7D"
function initFollowerCount() {
// sets up sheet names and Instagram accounts
insertFollowerCount("sheet1", "kingandmcgaw");
insertFollowerCount("sheet2", "nickboyce");
}
function insertFollowerCount(sheetName, instagramAccountName) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
sheet.appendRow([Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd"), getInstagramFollowerCount(instagramAccountName)]);
function initTwitterFollowerCount() {
insertTwitterFollowerCount("IG followers", "nickboyce");
}
function insertTwitterFollowerCount(sheetName, username) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheetName);
Logger.log(sheet.getRange("A1").getValue());
sheet.appendRow([Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd"), getTwitterFollowerCount(username)]); 
}