Connecting Google
Integrate Google services with af-gemini-connect
Overview
Connecting Google services enables powerful marketing and analytics capabilities:
- Google Analytics 4 (GA4) — Track website traffic and user behavior
- Google Search Console (GSC) — Monitor search performance and indexing
- Google Business Profile (GBP) — Manage local business listings
- Google Ads — Create and manage paid advertising campaigns
This guide covers setting up Google OAuth connections for all these services.
Prerequisites
Before starting, ensure you have:
- Google account with admin access to the desired services
- Google Cloud Project with OAuth 2.0 credentials
- Owner/Editor access to the Google properties you want to connect
Step-by-Step Connection
1. Create a Google Cloud Project
- Go to Google Cloud Console
- Click Create Project
- Enter a project name (e.g., "af-gemini-connect")
- Click Create
2. Enable Required APIs
- In your Cloud Project, go to APIs & Services → Library
- Enable the following APIs:
- Google Analytics API
- Google Search Console API
- Google My Business API (for GBP)
- Google Ads API
- Google Sheets API (optional, for data export)
3. Create OAuth 2.0 Credentials
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth 2.0 Client ID
- Configure the consent screen:
- Application type: Web application
- Name: af-gemini-connect
- Authorized redirect URIs: Add
https://your-domain.com/oauth/google/callback
- Click Create
- Copy the Client ID and Client Secret
4. Configure Google Connection in af-gemini-connect
- In af-gemini-connect, go to Admin → Integrations
- Select Google tab
- Click Connect Google Account
- Paste your Client ID and Client Secret
- Click Authenticate
- Approve the OAuth consent screen
5. Select Properties to Connect
After authentication, you'll see a list of available Google properties:
- GA4 Properties — Select which properties to connect
- Search Console Sites — Choose which sites to monitor
- Google Business Profiles — Select locations to manage
- Google Ads Accounts — Connect manager or client accounts
Creating GA4 & Search Console for a Website
For GA4 and Search Console specifically, there's a faster path than connecting properties one by one: on a client's Connections tab, click Create next to GA4 or Search Console instead of just Connect. This creates a new GA4 property and a new Search Console property for that website, adds the tracking tag to the site, checks that it's live, and binds both to the website automatically.
This one-click Create flow only works for GitHub-backed websites (v1 supports Next, React, Vite, and Nuxt site sources). For other website types, connect and bind a GA4 property or Search Console site manually instead.
The first time you use it on a site, watch for this extra step:
- If the site's source isn't one of the frameworks the system recognizes automatically, it doesn't fail — it hands the job to a Command AI agent, which patches the site's code to add the tracking tag.
- You'll see a message that a Command patch agent has started, with an Open Command link. Click it to watch the patch happen, or come back to it later.
- Once the Command run and the site's deployment both finish, Search Console finishes creating and binding on its own — you don't need to click Create again.
This can take a few minutes while the site redeploys and Google re-verifies it. If it's still not done after several minutes, a message will ask you to click Create once more to finish it manually — that only happens if the automatic retry runs out of attempts.
Connection Health Monitoring
Once connected, monitor your Google integrations in the Integrations dashboard:
- Connection Status: Active/Inactive
- Last Sync: When data was last refreshed
- API Limits: Usage vs. quota limits
- Error Logs: Any API errors or failures
Troubleshooting
"Invalid credentials" error
- Verify your Client ID and Client Secret are correct
- Ensure the Google Cloud Project is in the same organization as your properties
- Check that the APIs are enabled for your project
Missing properties in the list
- Confirm you have admin access to the properties
- Check that the properties are in the same Google account
- Try disconnecting and reconnecting
API quota exceeded
- Review your API usage in Google Cloud Console
- Request quota increase if needed
- Reduce sync frequency or data volume
Token refresh failures
- Verify your redirect URI is correctly configured
- Check for IP restrictions in OAuth settings
- Ensure your app is not blocked by Google's security review
Best Practices
- Use a dedicated Google account for your agency to manage all connections
- Set up proper IAM roles so team members have appropriate access
- Monitor API usage to avoid hitting daily limits
- Regularly review connected properties to ensure they're still active
- Implement error handling to gracefully handle connection failures
Next Steps
After connecting Google services, you can:
- Set up automated GA4 reporting
- Monitor search performance with GSC
- Manage GBP listings and reviews
- Create and optimize Google Ads campaigns
- Sync data to Google Sheets for analysis
FAQ
Q: Can I connect multiple Google accounts?
A: Yes, you can connect multiple 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 a property?
A: Disconnecting will stop data collection and may affect reports that rely on that data.
Q: Are there limits on API calls?
A: Yes, Google imposes daily quotas. Monitor usage in the Cloud Console.
