0
Installation
Install dependencies & start the server
cd ad-tracker-web
npm install
node server.js
Then open http://localhost:3000 and click Settings to enter your credentials.
1
Meta (Facebook) Ads API
App ID
App Secret
Long-lived Access Token
Ad Account ID
Step 1 — Create a Meta App
- Go to developers.facebook.com/apps
- Click Create App → choose Other → Business
- Give it any name (e.g. "Ad Tracker")
- From the app dashboard, click Add Product → add Marketing API
- Your App ID and App Secret are in Settings → Basic
Step 2 — Generate a Long-lived Access Token
- Go to Graph API Explorer
- Select your app from the dropdown
- Click Generate Access Token — grant
ads_readandread_insights - Exchange the short-lived token for a long-lived one (valid ~60 days):
curl "https://graph.facebook.com/oauth/access_token\
?grant_type=fb_exchange_token\
&client_id=YOUR_APP_ID\
&client_secret=YOUR_APP_SECRET\
&fb_exchange_token=SHORT_LIVED_TOKEN"
The access_token in the response is your long-lived token. Paste it into Settings.
Token expiry: Long-lived tokens last ~60 days. You'll need to regenerate one when it expires. You can automate this with a system user token — see Meta docs for details.
Step 3 — Find your Ad Account ID
- Go to business.facebook.com
- Navigate to Business Settings → Accounts → Ad Accounts
- Your Ad Account ID looks like
act_1234567890— enter only the numbers (noact_)
| Settings field | Where to find it |
|---|---|
| App ID | App dashboard → Settings → Basic |
| App Secret | App dashboard → Settings → Basic (click Show) |
| Access Token | Generated in Step 2 above |
| Ad Account ID | Business Manager → numbers only, no "act_" |
2
Google Ads API
Developer Token
Client ID
Client Secret
Refresh Token
Customer ID
Step 1 — Apply for a Developer Token
- Sign in at ads.google.com
- Go to Tools & Settings → API Center
- Fill out the form and submit — a Basic Access (test) token is sufficient to get started
- The token appears in the API Center once approved
Test vs Standard access: Basic Access works fine for reading your own account data. Standard Access is only needed if you're building a product for other advertisers.
Step 2 — Create OAuth 2.0 Credentials
- Go to console.cloud.google.com
- Create a new project (or select an existing one)
- Navigate to APIs & Services → Library → enable Google Ads API
- Go to APIs & Services → Credentials → Create Credentials → OAuth Client ID
- Choose Desktop App and give it a name
- Download the JSON file — it contains your Client ID and Client Secret
Step 3 — Generate a Refresh Token
Run this one-time script to get a refresh token via the OAuth flow:
npm install -g google-auth-library
node -e "
const { OAuth2Client } = require('google-auth-library');
const http = require('http');
const url = require('url');
const open = require('open');
const CLIENT_ID = 'YOUR_CLIENT_ID';
const CLIENT_SECRET = 'YOUR_CLIENT_SECRET';
const client = new OAuth2Client(CLIENT_ID, CLIENT_SECRET, 'http://localhost:4000');
const authUrl = client.generateAuthUrl({
access_type: 'offline',
scope: ['https://www.googleapis.com/auth/adwords'],
});
console.log('Opening browser...');
const server = http.createServer(async (req, res) => {
const code = new url.URL(req.url, 'http://localhost:4000').searchParams.get('code');
if (code) {
const { tokens } = await client.getToken(code);
console.log('\\nRefresh token:', tokens.refresh_token);
res.end('Done! Check your terminal.');
server.close();
}
});
server.listen(4000, () => require('child_process').exec('open \"' + authUrl + '\"'));
"
Or use the simpler Python approach if you have Python available:
pip3 install google-auth-oauthlib
python3 -c "
from google_auth_oauthlib.flow import InstalledAppFlow
flow = InstalledAppFlow.from_client_secrets_file(
'client_secrets.json',
scopes=['https://www.googleapis.com/auth/adwords']
)
creds = flow.run_local_server()
print('Refresh token:', creds.refresh_token)
"
Step 4 — Find your Customer ID
- Sign in at ads.google.com
- Your Customer ID is the 10-digit number in the top right — e.g.
123-456-7890 - Enter it with or without dashes — both work
| Settings field | Where to find it |
|---|---|
| Developer Token | Google Ads → Tools → API Center |
| Client ID | Google Cloud Console → Credentials |
| Client Secret | Google Cloud Console → Credentials |
| Refresh Token | Generated via OAuth flow in Step 3 |
| Customer ID | Top-right of Google Ads UI |
3
Troubleshooting
| Error | Fix |
|---|---|
| Invalid OAuth access token (Meta) | Your token expired (60-day limit). Regenerate via Graph API Explorer. |
| Request had invalid authentication credentials (Google) | Refresh token was revoked. Re-run the OAuth flow in Step 3. |
| No data showing | Your account may have no activity in the selected date range. Try "Last 30d". |
| Developer token not approved | Basic Access is enough for your own account. Check Google Ads API Center status. |
| ROAS shows N/A | Conversion value tracking needs to be set up in your ad account (e.g. purchase value pixel events). |