1. Opening Problem Statement
Meet Sarah, a digital marketer managing multiple clients’ websites. Every month, she needs to gather detailed analytics reports, especially session counts by country, from Google Analytics and compile them into Airtable for easy sharing with her team. Manually exporting reports and copying data into Airtable is tedious, error-prone, and takes hours, delaying her team’s access to insights.
Sarah’s frustration grows as she risks data entry errors, duplicated work, and lost productivity. What if she could automate this process to save her several hours each month and eliminate manual mistakes?
2. What This Automation Does
This n8n workflow automates Sarah’s monthly Google Analytics data collection and storage by:
- Triggering data fetch with a simple manual start
- Querying Google Analytics for session metrics broken down by country over a defined date range
- Transforming and formatting the raw analytics data for Airtable compatibility
- Appending each countryโs session data as new records into an Airtable table
- Eliminating manual exports, copy-pasting, and errors
- Saving Sarah at least 2-3 hours per month on routine reporting
3. Prerequisites โ๏ธ
- Google Analytics account with API access and a valid View ID๐
- Airtable account with a base and table prepared to receive session data๐
- n8n account (cloud or self-hosted) ๐
- Google Analytics OAuth2 credentials set up in n8n ๐
- Airtable API credentials stored in n8n ๐
4. Step-by-Step Guide
Step 1: Set up the Manual Trigger in n8n
Log into n8n, create a new workflow, and add the Manual Trigger node by clicking “Add Node” โ Searching “Manual Trigger” โ Select it. This node lets you start the workflow manually for ad-hoc data fetching.
After placing it, don’t add parameters; just position it on the canvas.
Outcome: You will have a workflow you can kick off anytime with a click.
Step 2: Configure the Google Analytics Node
Add the Google Analytics node next to the Manual Trigger node. Connect the Manual Trigger’s output to this node’s input.
Set the View ID parameter to your Google Analytics view ID (found in GA settings).
Under Additional Fields, configure your metrics and dimensions:
- Metrics: Add “ga:sessions” to capture sessions.
- Dimensions: Add “ga:country” to break down sessions by country.
- Date Range: Set a startDate and endDate for your desired reporting period. For instance, “2019-12-31” to “2020-08-30”.
Choose your Google Analytics OAuth2 credential in the credential field.
Common mistake: Forgetting to set the View ID or entering an incorrect date format results in API errors.
Outcome: This node fetches session counts per country for the defined period.
Step 3: Process Data with the Set Node
Add a Set node after the Google Analytics node to format and rename the incoming data for Airtable.
In the Set node, add two fields:
- Metric (Number type) with value
{{$json["total"]}}to capture sessions - Country (String type) with value
{{$json["ga:country"]}}
Enable Keep Only Set option to clear extraneous data.
Outcome: The data is cleaned and shaped ready for Airtable insertion.
Step 4: Append Data to Airtable
Add the Airtable node and connect the Set node to it.
Configure the Airtable node to Append records to your specific table (e.g., “Table 1”).
Select the Airtable API credential you’ve created in n8n.
Ensure your Airtable base has matching fields named exactly Metric and Country to receive data properly.
Common mistake: Field names mismatch causes data not to appear in Airtable.
Outcome: Each run adds new session data by country as separate records.
5. Customizations โ๏ธ
- Change Metrics: In the Google Analytics node, add or replace metrics like “ga:users” or “ga:bounceRate” to capture different data.
- Modify Date Range: Use n8n expressions or variables to automate date range changes based on the current date.
- Filter Countries: Add a Function node between Google Analytics and Set nodes to include only selected countries (e.g., US, UK).
- Update vs Append: Configure the Airtable node for “Update” mode using record IDs to avoid duplicates if re-running for same dates.
- Add Email Notification: Extend by adding a Gmail node to email yourself the update summary after appending to Airtable.
6. Troubleshooting ๐ง
Problem: “Invalid View ID or Unauthorized”
Cause: Either View ID is wrong, or OAuth credentials lack permissions.
Solution: Double-check the View ID in Google Analytics; regenerate and connect valid OAuth credentials in n8n’s Google Analytics node.
Problem: “Failed to Append Records in Airtable”
Cause: Field name mismatches or API rate limits hit.
Solution: Verify Airtable field names match exactly “Metric” and “Country” with correct data types; check API usage limits on Airtable dashboard.
7. Pre-Production Checklist โ
- Verify Google Analytics OAuth2 credentials are valid and scoped for reading data.
- Confirm View ID accuracy and data availability for the selected date range.
- Ensure Airtable base and table have fields “Metric” (number) and “Country” (text) matching your workflow.
- Test manual trigger to verify data retrieval and insertion without errors.
- Back up your Airtable data before large data inserts to prevent accidental overwrites.
8. Deployment Guide
Activate your workflow by toggling it ON in n8n.
Run the workflow manually initially via the Manual Trigger node to confirm data flows correctly.
For repeated automated execution, replace the Manual Trigger with a Cron node configured to run monthly or as needed.
Monitor executions via n8n’s execution log, verifying successful Airtable inserts.
9. FAQs
Q: Can I use another database like Google Sheets instead of Airtable?
A: Yes, n8n supports many data storage nodes; just swap the Airtable node with a Google Sheets node configured to append rows.
Q: Does this workflow consume a lot of API quota?
A: Google Analytics API calls per run are limited and generally low; Airtable’s API limits depend on your plan but typical usage for this scale is well within free tier.
Q: Is my data secure in n8n?
A: Yes, n8n encrypts credentials and data flows within your environment. Self-hosting adds further control over data privacy.
10. Conclusion
You have successfully built a n8n workflow to extract session analytics by country from Google Analytics and store that data into Airtable automatically.
You saved hours of manual reporting each month and minimized error risks. This automation allows you to focus on data analysis instead of data gathering.
Try extending your workflow by adding email notifications, automating date ranges, or integrating other metrics from Google Analytics to deepen insights.
Keep experimenting with n8nโyour automation ally for smarter work! โ๏ธ