Created
June 23, 2015 03:39
-
-
Save chipoglesby/405aca3ea1acf5b808cc to your computer and use it in GitHub Desktop.
Pull Facebook Advertising Metrics into Google Sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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