Automated Weekly Google Analytics Report Generation and GPT Analysis - n8n Workflow

Automate weekly Google Analytics reporting using this powerful n8n workflow. Schedule data retrieval, compare week-over-week metrics, analyze results with GPT-4o, and send PDF reports via Gmail. This is a robust n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Digital Marketing Managers needing automated weekly performance summaries.
SEO Specialists who require week-over-week comparisons of core web metrics.
Technical Analysts looking for advanced n8n templates integrating reporting and AI.
Anyone seeking to leverage the n8n platform to minimize manual data compilation.

Overview

Manually compiling weekly Google Analytics (GA) reports is a tedious and time-consuming process. This comprehensive n8n workflow solves this by fully automating the data pipeline, from extraction to delivery and analysis. The solution uses the power of the n8n platform to fetch key GA metrics (Users and Page Views) for the current and previous week, calculates the variance, and feeds this structured data directly into an OpenAI n8n node (GPT-4o-mini). The AI provides a detailed analysis, identifies critical trends, and suggests actionable recommendations. The resulting report is formatted into an HTML template, converted to a professional PDF attachment, and delivered via Gmail. This robust n8n workflow ensures timely, insightful reporting without manual intervention, providing an excellent example of practical n8n templates.

How it Works

This complex n8n workflow is initiated by an essential n8n trigger and executes the following steps:


  1. Schedule Trigger: The n8n workflow starts weekly using the Schedule Trigger n8n node.

  2. Date Calculation: A Code n8n node (Generate Date Range) calculates the exact 7-day ranges needed for the current and previous weeks.

  3. Data Retrieval: Two parallel Google Analytics n8n nodes (GA This Week and GA Last Week) pull core metrics (Users, Page Views) for the respective date ranges, utilizing the calculated dates.

  4. Data Aggregation & Comparison: The data is aggregated, combined using a Merge n8n node, and then processed by the Calculate Differences Code n8n node, which calculates the critical week-over-week percentage change.

  5. AI Analysis: The crucial step involves the Message a model1 (OpenAI) n8n node. It receives the calculated differences and uses GPT-4o-mini to generate an analytical summary, assessment, and recommendations, formatted strictly as raw HTML.

  6. Chart Generation: The Generate chart Code n8n node creates a configuration for a bar chart comparing the two weeks' raw data and generates a QuickChart URL for visualization.

  7. Report Finalization: The Report template HTML n8n node integrates the AI-generated report content and the generated chart image URL into a complete, professional report structure.

  8. PDF Export: The HTML to PDF n8n node converts this compiled HTML document into a shareable PDF file.

  9. Delivery: The final Gmail n8n node sends the weekly report email, including a hyperlink to the generated PDF URL. This complete n8n workflow automates the entire reporting process.

Installation Guide

To use this advanced n8n workflow template, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance using the "New -> Import from JSON" option.

  2. Set up Google Credentials: You must create and link Google OAuth2 credentials. Ensure the following APIs are enabled in your Google Cloud Console: Gmail API, Google Analytics Admin API, and Google Analytics Data API. Update the credentials used by the Gmail and Google Analytics n8n nodes.

  3. Set up OpenAI Credentials: Set up your API key credential for the OpenAI n8n node (Message a model1).

  4. Set up HTML to PDF: This n8n node requires installation and a specific API key (e.g., from PDFMunk). Configure the credential for the HTML to PDF n8n node.

  5. Configure Parameters: In the Google Analytics n8n nodes (GA This Week and GA Last Week), update the Property ID to match your Google Analytics 4 property ID. In the Send a message Gmail n8n node, replace the placeholder recipient email address.

  6. Activate: Save and activate the n8n workflow. The Schedule Trigger n8n trigger will run weekly based on its configuration.

Node Details

Schedule Trigger: The primary n8n trigger. It is configured for a weekly interval, ensuring the automated report runs every seven days.
Code Nodes (Generate Date Range, Extract GA, Calculate Differences, Generate chart): These custom scripting n8n nodes handle complex logic: calculating dynamic date windows, aggregating data from the GA responses, computing week-over-week percentage changes, and dynamically generating the visualization URL for the chart.
Google Analytics n8n node (GA This Week, GA Last Week): Configured to retrieve essential GA4 data points—totalUsers and screenPageViews—by linking to a specific Property ID and using dynamic date parameters passed from the previous n8n node.
OpenAI n8n node (Message a model1): The core intelligence of this n8n workflow. It uses the gpt-4o-mini model to analyze the calculated metrics and generate a detailed summary, assessment, and actionable recommendations, requested strictly in HTML format.
HTML n8n node (Report template): This n8n node assembles the final report by embedding the AI-generated text and the QuickChart image URL into a professional HTML structure.
HTML to PDF n8n node: Converts the final HTML report into a PDF document, allowing for a standardized, shareable output format.


  • Gmail n8n node (Send a message): The final delivery step, sending the email with the subject 'GA: Weekly report' and attaching the generated PDF document via its URL.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by
Satoshi
Satoshi

As an Information Technology Engineer with over 10 years of experience, I possess solid knowledge in AI as well as core operations such as Logistics, E-commerce, and CRM. Currently, I focus on creating automation solutions that address real-world challenges.

Featured*