Skip to main content

Automate google analytics reporting

Workflow preview

Workflow preview
100%
Automate google analytics reporting preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

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 ca...

Best for

  • Document Extraction automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, n8n-nodes-base.stickynote, n8n-nodes-base.googleanalytics, n8n-nodes-base.code, n8n-nodes-base.set, n8n-nodes-base.gmail, n8n-nodes-base.scheduletrigger

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Alex Kim.

Original n8n.io source

1.1 Workflow description

Title
Automate google analytics reporting
Workflow name
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 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

  1. 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:

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

  1. 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

  1. Run the Workflow
    • Trigger the workflow to fetch, process, and format Google Analytics data.
  2. 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.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Get Page Engagement Stats for this week

Type / Role
n8n-nodes-base.googleAnalytics - googleAnalytics
Config choices
Version 2

Block 5 - Get Page Engagement Stats for prior week

Type / Role
n8n-nodes-base.googleAnalytics - googleAnalytics
Config choices
Version 2

Block 6 - Get Google Search Results for this week

Type / Role
n8n-nodes-base.googleAnalytics - googleAnalytics
Config choices
Version 2

Block 7 - Get Country views data for this week

Type / Role
n8n-nodes-base.googleAnalytics - googleAnalytics
Config choices
Version 2

Block 8 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Aggregate Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Get Google Search Results for prior week

Type / Role
n8n-nodes-base.googleAnalytics - googleAnalytics
Config choices
Version 2

Block 11 - Get Country views data for prior week

Type / Role
n8n-nodes-base.googleAnalytics - googleAnalytics
Config choices
Version 2

Block 12 - Parse - Get Page Engagement This Week

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 13 - Parse - Get Page Engagement Prior Week

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 14 - Parse - Get Google Search This Week

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Parse - Get Google Search Prior Week

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - Parse - Country Views This Week

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 17 - Parse - Country Views Prior Week

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 18 - Set urlStrings

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - Format Data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 20 - Input All

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 21 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Email the Report

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 23 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

3. Summary Table

Workflow Automate google analytics reporting
Complexity advanced
Nodes 23
Categories Document Extraction
Author Alex Kim
Published 15 Nov 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2549/2549.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automate google analytics reporting do?

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 ca...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Document Extraction use case.