Connecting Meta Ads
Integrate Facebook and Instagram Ads with af-gemini-connect
Overview
Connecting Meta Ads enables powerful advertising automation:
- Campaign creation and management
- Audience targeting and optimization
- Ad creative generation
- Performance monitoring
- Automated budget allocation
This guide walks you through setting up the Meta Ads connection.
Prerequisites
Before you begin, ensure you have:
- Meta Business Suite account with admin access
- Facebook Page with publishing permissions
- Instagram Professional Account (optional, for IG ads)
- Meta Ads API access enabled
- af-gemini-connect account with integration permissions
Step-by-Step Connection
1. Create a Meta App
- Go to Meta for Developers
- Log in with your agency account
- Click My Apps → Create App
- Select Business as the app type
- Enter app details:
- App Name: af-gemini-connect
- Contact Email: [email protected]
- App Purpose: Manage ads and business assets
- Click Create
2. Configure App Settings
- In your new app, go to Settings → Basic
- Add Platform → Website
- Enter your website URL:
https://your-domain.com - Go to Products → Marketing API
- Click Create Token
- Generate a System User token with ads management permissions
3. Create a System User
- Go to Roles → System Users
- Click Create System User
- Enter a name (e.g., "af-gemini-connect Bot")
- Assign the following permissions:
ads_readads_managementpages_read_engagementpages_manage_postsinstagram_basic_display
- Generate an access token with these permissions
4. Connect Business Assets
- Go to App Review
- Click Start a Submission
- Request the following permissions:
ads_managementpages_read_engagementpages_manage_postsinstagram_basic_display
- Submit for review (this can take 1-3 business days)
5. Configure Connection in af-gemini-connect
- In af-gemini-connect, go to Admin → Integrations
- Select Meta Ads tab
- Click Connect Meta Ads
- Enter your App ID and App Secret
- Click Authenticate
- Approve the OAuth consent screen
6. Select Business Assets
After authentication, select which assets to connect:
- Ad Accounts — Choose which ad accounts to manage
- Facebook Pages — Select pages for instant experience
- Instagram Accounts — Connect professional IG accounts
- Business Manager — Link your entire business suite
Connection Health Monitoring
Once connected, monitor your Meta Ads integration in the Integrations dashboard:
- Connection Status: Active/Inactive
- API Limits: Usage vs. rate limits
- Last Sync: When campaign data was last refreshed
- Error Logs: Any API errors or failures
Troubleshooting
"App not configured" error
- Verify your app is in development mode and has the required permissions
- Ensure you've completed the app review process
- Check that your system user has the correct permissions
Missing ad accounts or pages
- Confirm you have admin access to the assets
- Check that assets are part of your Business Manager
- Verify the assets are assigned to the correct app
API rate limit errors
- Review your API usage in the Meta for Developers dashboard
- Implement exponential backoff in your requests
- Request a quota increase if needed
Token expiration issues
- Ensure your system user token has the correct expiration
- Set up automatic token refresh using the app secret
- Monitor token health in the integrations dashboard
Best Practices
- Use a dedicated business account for your agency's API access
- Set up proper permission tiers so team members have appropriate access
- Monitor API usage to avoid hitting rate limits
- Regularly review connected assets to ensure they're still active
- Implement error handling to gracefully handle API failures
Next Steps
After connecting Meta Ads, you can:
- Set up automated campaign creation
- Configure audience targeting rules
- Generate ad creatives with AI
- Set up performance monitoring dashboards
- Implement budget optimization algorithms
FAQ
Q: Can I connect multiple Meta Business accounts?
A: Yes, you can connect multiple business accounts, but each client should have their own dedicated connection.
Q: How often does data sync?
A: Sync frequency is configurable from every 15 minutes to daily.
Q: What happens if I disconnect an asset?
A: Disconnecting will stop data collection and may affect automated campaigns.
Q: Are there limits on API calls?
A: Yes, Meta imposes rate limits. Monitor usage in the developer dashboard.
Q: Can I manage Instagram ads without a professional account?
A: No, Instagram ads require a professional account linked to a Facebook Page.
