How to Track Instagram Metrics For Free

Record straight to Google Sheets

https://stocksnap.io/photo/S3JE5YAMND

We’ve recently expanded our team to deal with some of the more specialist topics that none of the founders are that interested in (or good at).

On one hand, it’s great because people that are better than us are handling things we don’t necessarily enjoy.

On the other, you risk feeling detached and the worry is that a problem could arise and wreak havoc, without you knowing it’s coming.

Reporting is one small step towards solving this. But come on, nobody enjoys writing the damn things. It’s crazy boring and in lets face it very few people are going to read it.

Dynamic tracking seems much more effective.

Stage 1: Do it Manually

Instead of a monthly written report, just ask your team to keep a relevant chart up to date.

For social media and/or Instagram that could just be a case of

DATE
FOLLOWERS
FOLLOWING
NUMBER OF POSTS

With just those four data points you can do a bunch of useful analytics and see in broad terms how well you/your team are performing.

All your team has to do is update the spreadsheet in a shared folder at an agreed interval.

Stage 2: Automate

If you want to really kick it up a notch and don’t want to pay for analytics, Instagram have kindly published all the data above without requiring API access.

https://www.instagram.com/yourHandle/?__a=1

It looks scary — like this…

Don’t worry, it’s not as scary as it first looks. In there you have information about recent posts, comments, likes, followers, following, total posts etc.

All you need to do now is extract it and store it on Google Drive so you can access it at any time from anywhere.

Open Up A Google Sheet

Go to your google account and create a new google sheet.

We use Google for business so it’s included. This also works with any free gmail account.

Then open up your Script Editor

open this

You’ll have to grant access for this script editor to run on your sheet, but don’t worry you only have to do this once.

NB: Google Scripts runs javascript. It’s a lightweight language, and pretty straightforward to pick up. Even if you’ve never done web development before (my background is data analytics and simulations).

Add Some Code

Once your script editor is open just copy and paste the code below.

This adds a new line every time you run the code and tracks the data we discussed before.

// the name of the sheet within your document
var sheetName = "Instagram";
// the name of the Instagram account you want the follower count for
var instagramAccountName = "yourInstagramHandle";
function insertInstagramFollowerCount() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(this.sheetName);
sheet.appendRow([Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd"), getInstagramFollowerCount(this.instagramAccountName), getInstagramFollowingCount(this.instagramAccountName), getInstagramPosts(this.instagramAccountName)]);
};
function getInstagramFollowerCount(username) {
var url = "https://www.instagram.com/" + username + "/?__a=1";
var response = UrlFetchApp.fetch(url).getContentText();
return JSON.parse(response).user.followed_by.count;
}
function getInstagramFollowingCount(username) {
var url = "https://www.instagram.com/"+username+"/?__a=1";
var response = UrlFetchApp.fetch(url).getContentText();
return JSON.parse(response).user.follows.count;
}
function getInstagramPosts(username){
var url = "https://www.instagram.com/"+username+"/?__a=1";
var response = UrlFetchApp.fetch(url).getContentText();
return JSON.parse(response).user.media.count;
}

When you’re done it’ll look something like this. Don’t forget to put in your own instagram handle and name the sheet you are using.

To run the programme select the debug button (looks like a little bug) and select the insertInstagramFollowerCount function.

Run Every ____?

You’re now ready to run this automatically without any input from you. So you and your team can focus on growing your business.

Awesome right!

Just set a trigger in your code by clicking the trigger icon and setting your times.

select the trigger tool
set your triggers (I recommend the one here)

That’s it, your spreadsheet will now update every day without any input from you or your team.

So you can all focus on growing your business and not wasting precious time on reporting so often.


Troubleshooting

A quick one, you may find that your spreadsheet is updating but some entries are the same day?

This is likely because your spreadsheet is set to US time and your code is set to record results in GMT format.

Simply select Spreadsheet settings and ensure set to UK time.

Ensure spreadsheet is set to right timezone

Thanks for Reading
Thanks For Reading. If you enjoyed this how-to article please hit the 💚 button and let me know. You can also follow my latest venture on Instagram @DiscoveryHubHQ