Skip to content

Google Sheets Export

Use the GhostFlow API to automatically pull campaign statistics into Google Sheets using Apps Script.

  1. Create a new Google Sheet
  2. Go to Extensions → Apps Script
  3. Paste the following script:
function fetchGhostFlowStats() {
const API_KEY = PropertiesService.getScriptProperties().getProperty('GF_API_KEY');
const BASE_URL = 'https://devcore.getghostflow.io/api/v1';
const response = UrlFetchApp.fetch(`${BASE_URL}/reports/dashboard`, {
headers: { 'Authorization': `Bearer ${API_KEY}` }
});
const data = JSON.parse(response.getContentText());
const sheet = SpreadsheetApp.getActiveSheet();
// Write headers
sheet.getRange('A1:E1').setValues([['Date', 'Clicks', 'Conversions', 'Revenue', 'ROI']]);
// Write data
const row = [new Date(), data.clicks, data.conversions, data.revenue, data.roi];
sheet.appendRow(row);
}
  1. Set your API key: Project Settings → Script Properties → Add GF_API_KEY
  2. Add a trigger to run daily: Triggers → Add Trigger → Time-driven → Day timer

Your API key needs: read:stats