.env file.
Configuration File
Template:~/workspace/source/.env.example
Your config: ~/workspace/source/data_sources/config/.env
Quick Setup
1. Copy Template
2. Fill in Your Credentials
Edit the.env file with your actual API credentials:
3. Never Commit Credentials
The.env file is gitignored. Never commit credentials to version control.
Required Environment Variables
Google Analytics 4 (GA4)
Required for traffic and engagement data.- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google Analytics Data API
- Create service account and download JSON key
- Add service account email to GA4 property (Viewer role)
- Save JSON file to
~/workspace/source/credentials/ga4-credentials.json - Find Property ID in GA4 Admin > Property Settings
Google Search Console (GSC)
Required for search rankings and impressions data.- Use same service account as GA4 or create new one
- Enable Google Search Console API in Cloud Console
- Add service account email as user in Search Console
- Save credentials to
~/workspace/source/credentials/gsc-credentials.json - Copy exact site URL from Search Console
DataForSEO
Required for SERP analysis, keyword research, and competitor data.- Sign up at dataforseo.com
- Get API credentials from dashboard
- Add $10-20 credit to start (pay-as-you-go pricing)
- Copy login email and API password
Optional Environment Variables
Blog Path Filter
Define your blog URL structure if not at/blog/.
- WordPress blog:
/blog/ - Ghost blog:
/articles/ - Custom blog:
/resources/blog/
Company Information
Optional variables to help with context.Credentials Files
Service Account JSON Files
Google API credentials are stored as JSON files:Security Best Practices
Do:- Store credentials in
credentials/directory (gitignored) - Use service accounts (not OAuth user credentials)
- Grant minimum required permissions
- Rotate credentials periodically
- Commit credentials to version control
- Share credentials files
- Use personal Google account credentials
- Grant unnecessary permissions
Testing Your Configuration
Test API Connectivity
Verify your credentials work:Test Data Sources
Run a simple data fetch:Troubleshooting
”Credentials file not found”
Problem: Python scripts can’t find credentials files. Solution:-
Verify file exists:
-
Check path in
.envis correct: -
Ensure path is relative to where scripts run (usually repo root):
“Permission denied” errors
Problem: Service account doesn’t have access. Solution:-
Verify service account email in credentials file:
-
Add that email to:
- GA4 property (Admin > Property Access Management)
- Search Console (Settings > Users and Permissions)
-
Grant appropriate permissions:
- GA4: Viewer role
- GSC: Owner or Full user
”API not enabled” errors
Problem: Required APIs aren’t enabled in Google Cloud. Solution:- Go to Google Cloud Console
- Select your project
- Navigate to APIs & Services > Library
- Enable:
- Google Analytics Data API
- Google Search Console API
DataForSEO authentication fails
Problem: Invalid login or password. Solution:- Verify credentials in DataForSEO dashboard
- Ensure you’re using API password (not account password)
- Check for typos in
.envfile - Ensure account has credit (minimum $10)
Environment Variables by Command
Research Commands
Commands that use environment variables:Performance Commands
Commands that use environment variables:Analytics Scripts
Python scripts that use environment variables:Security Checklist
Before committing any code:-
.envfile is in.gitignore - No credentials in source code
- Credentials files in gitignored directory
- Service accounts have minimum required permissions
- No credentials in commit history
-
.env.examplehas placeholders only, no real values
Next Steps
Google Analytics Setup
Detailed GA4 configuration guide
Google Search Console
Complete GSC setup instructions
DataForSEO Setup
Configure DataForSEO API access
Research Commands
Start researching with your data sources