Google Sheets Export
Overview
Section titled “Overview”Use the GhostFlow API to automatically pull campaign statistics into Google Sheets using Apps Script.
- Create a new Google Sheet
- Go to Extensions → Apps Script
- 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);}- Set your API key: Project Settings → Script Properties → Add
GF_API_KEY - Add a trigger to run daily: Triggers → Add Trigger → Time-driven → Day timer
Required Scopes
Section titled “Required Scopes”Your API key needs: read:stats