-
-
Save IronistM/0ed6c9e22f94f7048533 to your computer and use it in GitHub Desktop.
Pull Facebook Advertising Metrics into Google Sheets
This file contains hidden or 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