Google Analytics
Google Analytics 4 (GA4) is a powerful analytics platform that helps you track and analyze user behavior across websites and mobile apps. It provides insights into customer journeys, marketing effectiveness, and conversion optimization. With GA4, you can measure traffic, understand user engagement, track conversions, and make data-driven decisions to improve your digital presence.
Authentication Types
Google Analytics supports 1 authentication method:
- OAuth - Standard OAuth 2.0 authentication for accessing Google Analytics data
- Pros: Secure, user-authorized access with fine-grained permission control through scopes
- Cons: Requires initial user consent and periodic token refresh
- Best for: Individual user access and applications requiring user-specific data access
Setting up OAuth
Follow these steps to configure OAuth authentication for Google Analytics:
1. Create a Google Cloud Project
- Go to the Google Cloud Console
- Click Select a project at the top of the page, then click New Project
- Enter a project name (e.g., "Webrix Analytics Integration")
- Click Create
2. Enable the Google Analytics APIs
- In your Google Cloud project, navigate to APIs & Services > Library
- Search for "Google Analytics Data API"
- Click on Google Analytics Data API and click Enable
- Go back to the API Library and search for "Google Analytics Admin API"
- Click on Google Analytics Admin API and click Enable
3. Configure the OAuth Consent Screen
- Navigate to APIs & Services > OAuth consent screen
- Select External as the User Type (or Internal if you're using Google Workspace and want to restrict to your organization)
- Click Create
- Fill in the required information:
- App name: Enter your application name (e.g., "Webrix")
- User support email: Select your email address
- Developer contact information: Enter your email address
- Click Save and Continue
- On the Scopes page, click Add or Remove Scopes
- Filter for "analytics" and select the scopes you need:
https://www.googleapis.com/auth/analytics.readonly(required for reading data)https://www.googleapis.com/auth/analytics(optional, for full access)https://www.googleapis.com/auth/analytics.edit(optional, for editing configuration)
- Click Update and then Save and Continue
- If using External user type, add test users who should have access during development
- Click Save and Continue to review, then click Back to Dashboard
4. Create OAuth 2.0 Credentials
- Navigate to APIs & Services > Credentials
- Click Create Credentials at the top and select OAuth client ID
- Select Web application as the Application type
- Enter a name for your OAuth client (e.g., "Webrix Web Client")
- Under Authorized redirect URIs, add your Webrix redirect URI:
- For Webrix Cloud:
https://app.webrix.ai/oauth/callback - For self-hosted: Your Webrix instance callback URL
- For Webrix Cloud:
- Click Create
- A dialog will appear with your Client ID and Client Secret
- Copy both values - you'll need them for Webrix configuration
5. Configure in Webrix
- Log in to your Webrix instance
- Navigate to Connectors or Integrations
- Find and select Google Analytics
- Choose OAuth as the authentication method
- Paste your Client ID from step 4
- Paste your Client Secret from step 4
- Select the OAuth scopes you need (at minimum, select
analytics.readonly) - Click Connect or Authorize
- You'll be redirected to Google to grant permissions
- Review the permissions and click Allow
- You'll be redirected back to Webrix with a successful connection
6. Verify the Connection
After authorization, you should:
- See a success message in Webrix
- Be able to select your Google Analytics properties
- Start querying your analytics data
Troubleshooting
"Access Not Configured" Error
Cause: The Google Analytics Data API or Admin API is not enabled for your project.
Solution:
- Go to the Google Cloud Console
- Select your project
- Navigate to APIs & Services > Library
- Search for and enable both:
- Google Analytics Data API
- Google Analytics Admin API
- Wait a few minutes for the changes to propagate
- Try connecting again
"Insufficient Permissions" or Scope Errors
Cause: The OAuth scopes configured don't match what your operations require.
Solution:
- Review which scopes you selected during OAuth setup
- For read-only operations (reports), ensure
analytics.readonlyis selected - For write operations (creating custom dimensions, key events), ensure
analytics.editoranalyticsis selected - In Webrix, update your connector configuration to include the necessary scopes
- Re-authorize the connection to grant the new permissions
"Property Not Found" or "User Does Not Have Access"
Cause: The authenticated user doesn't have access to the Google Analytics property you're trying to query.
Solution:
- Go to Google Analytics
- Verify you can see the property in the Analytics interface
- Check your property ID is correct (format:
properties/123456789or just123456789) - If you can't see the property, ask a Google Analytics administrator to grant you access
- Required access levels:
- Viewer role or higher for read operations
- Editor role or higher for configuration changes
- Administrator role for user management operations
OAuth Consent Screen Shows "Unverified App" Warning
Cause: Your OAuth application hasn't been verified by Google.
Solution:
- For development and testing, you can proceed past the warning by clicking Advanced > Go to [App Name] (unsafe)
- For production use with external users, consider submitting your app for verification (though not required for limited use)
- If using Google Workspace, you can publish the app for internal use only without verification
Tokens Expired or Invalid
Cause: OAuth access tokens expire after a period of time.
Solution:
- Webrix automatically refreshes expired tokens using the refresh token
- If refresh fails, you may need to re-authorize the connection
- Ensure your OAuth client credentials haven't been revoked in Google Cloud Console
- Check that the "access_type: offline" parameter is being used to obtain refresh tokens
Common Use Cases
Accessing Analytics Reports
Use the Run Report tool to query your analytics data:
- Specify dimensions (e.g.,
city,country,deviceCategory) - Specify metrics (e.g.,
activeUsers,sessions,conversions) - Set date ranges (e.g., last 7 days, last 30 days, specific date range)
- Apply filters to narrow results
- Essential for dashboards, automated reporting, and data analysis
Real-Time Monitoring
Use the Run Realtime Report tool to see live activity:
- Monitor active users on your site right now
- Track real-time conversions and events
- Debug tracking implementation
- Monitor campaign launches
Property Discovery
Use List Account Summaries or List Properties to:
- Discover available Google Analytics properties
- Get property IDs needed for reporting
- Audit account structure
Custom Configuration
- Create Custom Dimensions/Metrics to track business-specific data
- Create Key Events to mark important conversion points
- Manage Data Streams to configure web and app tracking
Audit and Compliance
- Use Run Access Report to monitor who accessed your data
- Use Search Change History to track configuration changes
- Essential for security auditing and compliance requirements