Automate google analytics reporting
Automate Google Analytics Reporting with n8n This n8n workflow collects, processes, and formats Google Analytics data into a comprehensive HTML report. The r...
🔌 Nodes & Integrations Used (2)
📖 Implementation & Setup Guide
Automate Google Analytics Reporting with n8n
This n8n workflow collects, processes, and formats Google Analytics data into a comprehensive HTML report. The report is segmented into three primary categories: Engagement Stats, Search Results, and Country Views. The formatted report can be emailed or saved as a document, and the workflow includes error handling and logging for better debugging.
Overview
Purpose
To automate the extraction, processing, and presentation of Google Analytics data in a visually appealing and structured format for easier insights and decision-making.
Features
- **Data Parsing**: Individual parsers process raw Google Analytics data for different time periods and categories.
- **Data Aggregation**: Combines parsed data into a single structured JSON object.
- **HTML Report Generation**: Formats the aggregated data into an HTML table with color-coded segments for better readability.
- **Email or Document Output**: The formatted report can be emailed or saved as a Google Doc (will need additional setup).
- **Error Handling**: Includes checks for missing data and detailed error messages for debugging.
Workflow Steps
- **Data Fetching**:
- Six separate Google Analytics data pulls:
- - Page Engagement Stats (This Week and Prior Week)
- - Google Search Results (This Week and Prior Week)
- - Country Views (This Week and Prior Week)
2. **Data Parsing**:
- Each data pull is processed using a dedicated parser node to generate a URL-safe string.
- - Example nodes:
- - `Parse - Get Page Engagement This Week`
- - `Parse - Country Views Prior Week`
3. **Data Aggregation**:
- Aggregates parsed data into a structured JSON object using the `Aggregate Data` node.
- - Ensures consistency and handles missing or malformed data.
4. **HTML Report Generation**:
- Creates a formatted HTML report with color-coded tables for each segment:
- - **Engagement Stats**: Green
- - **Search Results**: Blue
- - **Country Views**: Orange
- - Includes headers and neatly formatted tables for each data set.
5. **Output**:
- The report can be sent via email using the Gmail API or saved to Google Docs.
- - Example nodes:
- - `Gmail` node for email delivery.
- - `Google Docs` node for saving the report as a document.
Requirements
Prerequisites
- **Google Cloud Setup**:
- - Enable Google Analytics API.
- - Enable Gmail API (if using email output).
- - Generate OAuth credentials for API access.
- **n8n Installation**:
- - Self-hosted n8n instance with required nodes (Gmail, Google Docs, etc.).
- - [Free Cloud-based n8n account]( https://n8n.partnerlinks.io/alexk1919).
Environment Variables
- Ensure API credentials and tokens are set up in the n8n environment.
- Update the respective nodes with client ID, client secret, and access tokens.
Configuration
Google Analytics
- Configure the `Get Report` nodes with the appropriate property ID and metrics.
- Ensure correct date ranges are selected for each node.
Formatting Node
- The `Format Data` node processes aggregated data and generates the HTML content.
- Customize the HTML styling and segment colors as needed.
Email Node
- Configure the Gmail node with OAuth credentials.
- Set the recipient email address and subject line dynamically.
Error Handling
Common Issues
- **Authentication Errors**:
- Ensure OAuth credentials are correct.
- - Verify that the APIs are enabled in the Google Cloud Console.
2. **Empty Data**:
- Check the raw data from Google Analytics.
- - Validate the property ID and query parameters in the `Get Report` nodes.
3. **Parsing Errors**:
- Ensure the parser nodes are correctly configured and match the expected input format.
Debugging
- Use debug logs in each node to identify data flow issues.
- Add error-handling nodes to capture and log issues during execution.
Example Usage
- **Run the Workflow**
- - Trigger the workflow to fetch, process, and format Google Analytics data.
- **Verify Output**
- - Check the formatted HTML output in the debug logs.
- - Ensure the email or Google Doc contains the correctly formatted report.
Future Enhancements
- Add support for additional metrics or dimensions.
- Integrate with Slack for notifications.
- Enable scheduling for automated reports.
- Add a visual dashboard for real-time analytics.
---
⚡ How to import this workflow into n8n:
- Click the Direct Download JSON button above to save
Automate google analytics reporting.json. - Log in to your n8n Cloud or self-hosted n8n instance.
- In your workflow canvas, click the menu in top-right and select Import from File (or paste the JSON directly).
- Configure your credentials (e.g. API keys, database URLs) in the corresponding node settings.
- Click Execute Workflow to test and switch to Active!
Related Email & Outreach Workflows
View All in Email & Outreach →Abandoned cart recovery for Shopify via Gmail Google Sheets T
Who is this for? This template is ideal for solo store owners, eCommerce marketers, automation beginners, or anyone using Shopify and Gmail who wants to reco...
Add new leads in Lemlist from Airtable
This workflow allows you to add new leads in Lemlist from Airtable. !workflow-screenshot Airtable node: This node lists all the emails that are stored in you...
Add Subscriber and Send Email Campaign
Production-ready n8n automation template for Add Subscriber and Send Email Campaign built by AhiXLight. Seamlessly connects Sendy with 3 configured nodes.
Add new contacts from HubSpot to the email list in Mailchimp
This workflow adds new HubSpot contacts to the Mailchimp email list. Prerequisites - HubSpot account and HubSpot credentials - Mailchimp account and Mailchim...