Skip to content

Instantly share code, notes, and snippets.

@chipoglesby
Created June 23, 2015 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chipoglesby/405aca3ea1acf5b808cc to your computer and use it in GitHub Desktop.
Save chipoglesby/405aca3ea1acf5b808cc to your computer and use it in GitHub Desktop.
Pull Facebook Advertising Metrics into Google Sheets
var SPREADSHEET_URL = "";
function facebookSpend() {
var ss = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
var sheet = ss.getSheetByName('facebook');
var values = [];
Utilities.sleep(1000);
var fullUrl = 'https://graph.facebook.com/v2.3/act_xxx/stats?access_token=xxx';
var fetchRequest = UrlFetchApp.fetch(fullUrl);
var results = JSON.parse(fetchRequest.getContentText());
Logger.log(results.spent/100);
values.push('spend',results.spent/100);
sheet.appendRow(values);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment