How to use Google Docs and EngagedCount to monitor your blogs social engagement

Keeping track of your blog’s social engagement is important. Knowing your engagement numbers can help you figure out what topics resonate with your audience.

But how can you get access to update-to-date social engagement counts? Each social network has different APIs and different restrictions on access. EngagedCount was created to give users a unified way of getting engagement metrics across social networks.

Below I explain how to use EngagedCount and Google Sheets to create a spreadsheet that monitors engagement count for you.

Get an EngagedCount API key

Head over to EngagedCount and sign up for an account. A free account can be created with just an email address. After confirming your email you’ll gain access to your account page. There you can find your API key.

You’ll need the API Key later. Keep your account page open so you can easily copy and paste that key later.

Create a spreadsheet in Google Sheets

Going into your Google Drive and create a new spreadsheet. I named mine Engagement Tracker.

First add column headers to the spreadsheet. These aren’t required but I find adding headers greatly improves the readability of my spreadsheets. I labeled my columns URL, Facebook, LinkedIn, Pinterest, and Google Plus.

Now add the URLs you want to track to the first column. For this example I picked some comics from xkcd and some posts from thekitchn.com.

Now comes the tricker part. Click on the Tools menu item and select Script editor.

How to get to the script editor

This pops open the script editor. Once there, you should be looking at a blank text area. Lets start out by adding some code to fetch the total Facebook engagement count. Substitute in your EngagedCount API for YOUR_API_KEY_HERE. Copy and paste the below code into your empty script editor window. Once it is pasted, save it and give your Google Script project a name. I called my Engaged Api.

var apikey='YOUR_API_KEY_HERE'
function QueryEngagedCount(url) {
var response = UrlFetchApp.fetch('https://engagedcount.com/api?url=' + url + '&apikey=' + apikey);
var parsed = JSON.parse(response.getContentText());
return parsed;
}
function FacebookCount(url) { 
return QueryEngagedCount(url)["Facebook"]["total_count"];
}

The above code snippet hardcodes an API key and defines two functions. One function, QueryEngagedCount, takes a url as an argument and then queries EngagedCount’s API and returns the parsed response. The FacebookCount function uses QueryEngagedCount and then returns the total number of Facebook engagements.

Next, click the (1) Select Function drop down, select (2) FacebookCount, and then click the (3) Run button.

Three clicks to run the FacebookCount function

This will cause some prompts to appear asking you to grant your script permission to access external services. Click the buttons to allow your functions to call EngagedCount.

First prompt. Click “Review Permissions”
Second prompt. Click “Allow”

Once you do all that, switch back to your spreadsheet. Now you can use your FacebookCount function from your spreadsheet. In the cell next to your first URL, call FacebookCount and pass it your first URL.

Tada 🎉! After entering in the formula you will now see a number in the cell telling you the total Facebook engagement. Duplicate the cell containing the function down the column until you reach your last URL. Now you have Facebook engagement counts for all your URLs!

Awesome, now we have Facebook engagement counts showing up in our spreadsheet. Time to get the other networks.

To do this, switch back to the script editor and add the following function to the bottom of your script.

function AllEngagements(url) {
var engagementCounts = QueryEngagedCount(url);
return [[engagementCounts['Facebook']['total_count'],
engagementCounts['LinkedIn'],
engagementCounts['Pinterest'],
engagementCounts['GooglePlusOne']]];
}

The above function calls EngagedCount once and then returns the right shape of data so that each social network’s engagement count ends up in a separate column. Change your =FacebookCount(A2) to =AllEngagements(A2) and duplicate that function down the column.

Now we have a spreadsheet that fetches social engagement stats for a variety of social networks. A perfect tool for tracking the stats of whatever URLs you care about.