๐Ÿ”ฌ Automate google analytics reporting

โšก 17,952 views ยท ๐Ÿ”ฌ Document Extraction & Analysis

Description

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

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

Environment Variables

Configuration

Google Analytics

Formatting Node

Email Node

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

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


๐Ÿ”— Nodes Used

Gmail, Google Analytics, Schedule Trigger

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup