Back to Integrations
integrationGmail node
integrationGoogle Analytics node

Gmail and Google Analytics integration

Save yourself the work of writing custom integrations for Gmail and Google Analytics and use n8n instead. Build adaptable and scalable Communication, HITL, and Analytics workflows that work with your technology stack. All within a building experience you will love.

How to connect Gmail and Google Analytics

  • Step 1: Create a new workflow
  • Step 2: Add and configure nodes
  • Step 3: Connect
  • Step 4: Customize and extend your integration
  • Step 5: Test and activate your workflow

Step 1: Create a new workflow and add the first step

In n8n, click the "Add workflow" button in the Workflows tab to create a new workflow. Add the starting point – a trigger on when your workflow should run: an app event, a schedule, a webhook call, another workflow, an AI chat, or a manual trigger. Sometimes, the HTTP Request node might already serve as your starting point.

Gmail and Google Analytics integration: Create a new workflow and add the first step

Step 2: Add and configure Gmail and Google Analytics nodes

You can find Gmail and Google Analytics in the nodes panel. Drag them onto your workflow canvas, selecting their actions. Click each node, choose a credential, and authenticate to grant n8n access. Configure Gmail and Google Analytics nodes one by one: input data on the left, parameters in the middle, and output data on the right.

Gmail and Google Analytics integration: Add and configure Gmail and Google Analytics nodes

Step 3: Connect Gmail and Google Analytics

A connection establishes a link between Gmail and Google Analytics (or vice versa) to route data through the workflow. Data flows from the output of one node to the input of another. You can have single or multiple connections for each node.

Gmail and Google Analytics integration: Connect Gmail and Google Analytics

Step 4: Customize and extend your Gmail and Google Analytics integration

Use n8n's core nodes such as If, Split Out, Merge, and others to transform and manipulate data. Write custom JavaScript or Python in the Code node and run it as a step in your workflow. Connect Gmail and Google Analytics with any of n8n’s 1000+ integrations, and incorporate advanced AI logic into your workflows.

Gmail and Google Analytics integration: Customize and extend your Gmail and Google Analytics integration

Step 5: Test and activate your Gmail and Google Analytics workflow

Save and run the workflow to see if everything works as expected. Based on your configuration, data should flow from Gmail to Google Analytics or vice versa. Easily debug your workflow: you can check past executions to isolate and fix the mistake. Once you've tested everything, make sure to save your workflow and activate it.

Gmail and Google Analytics integration: Test and activate your Gmail and Google Analytics workflow

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

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)

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

Data Aggregation:

Aggregates parsed data into a structured JSON object using the Aggregate Data node.
Ensures consistency and handles missing or malformed data.

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.

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.

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.

Empty Data:

Check the raw data from Google Analytics.
Validate the property ID and query parameters in the Get Report nodes.

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.

Nodes used in this workflow

Popular Gmail and Google Analytics workflows

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 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) 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 Data Aggregation: Aggregates parsed data into a structured JSON object using the Aggregate Data node. Ensures consistency and handles missing or malformed data. 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. 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. 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. Empty Data: Check the raw data from Google Analytics. Validate the property ID and query parameters in the Get Report nodes. 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.
+8

Qualify and email literary agents with GPT‑4.1, Gmail and Google Sheets

Inspiration & Notes This workflow was born out of a very real problem. While writing a book, I found the process of discovering suitable literary agents and managing outreach to be manual, and surprisingly difficult to scale. Researching agents, checking submission rules, personalizing emails, tracking submissions, and staying organized quickly became a full-time job on its own. So instead of doing it manually, I automated it. I built this entire workflow in 3 days — and the goal of publishing it is to show that you can do the same. With the right structure and intent, complex sales and marketing workflows don’t have to take months to build. Contact & Collaboration If you have questions, business inquiries, or would like help setting up automation workflows, feel free to reach out: 📩 [email protected] I genuinely enjoy designing workflows and automation systems, especially when they support meaningful projects. I work primarily from interest and impact rather than purely financial motivation. Whether I take on a project for FREE or paid for the following reasons: I LOVE setting up workflows and automation. I work for meaningfulness, not for money. I may do the work for free**, depending on how meaningful the project is. If the problem statement matters, the motivation follows. It also depends on the value I bring to the table** -- If I can contribute significant value through system design, I’m more inclined to get involved. If you’re building something thoughtful and need help automating it, I’m always happy to have a conversation. Enjoy~! Overview Automates the end-to-end literary agent outreach pipeline, from data ingestion and eligibility filtering to deep agent research, personalized email generation, submission tracking, and analytics. Architecture The system is organized into four logical domains: The system is modular and is divided into four domains: --> Data Engineering --> Marketing & Research --> Sales (Outreach) --> Data Analysis Each domain operates independently and passes structured data downstream. Data Engineering Purpose: Ingest and normalize agent data from multiple sources into a single source of truth. Inputs Google BigQuery Azure Blob Storage AWS S3 Google Sheets (Optional) HTTP sources Key Steps Scheduled ingestion trigger Merge and normalize heterogeneous data formats (CSV, tables) Deduplication and validation AI-assisted enrichment for missing metadata Append-only writes to a central Google Sheet Output Clean, normalized agent records ready for eligibility evaluation Marketing & Research Purpose: Decide who to contact and how to personalize outreach. Eligibility Evaluation An AI agent evaluates each record against strict rules: Email submissions enabled Not QueryTracker-only or QueryManager-only Genre fit (e.g. Memoir, Spiritual, Self-help, Psychology, Relationships, Family) Outputs send_email (boolean) reason (auditable explanation) Deep Research For eligible agents only: Public research from agency sites, interviews, Manuscript Wish List, and LinkedIn (if public) Extracts: Professional background Editorial interests Genres represented Notable clients/books (if publicly listed) Public statements Source-backed personalization angles Strict Rule: All claims must be explicitly cited; no inference or hallucination is allowed. Sales (Outreach) Purpose: Execute personalized email outreach and maintain clean submission tracking. Steps AI generates agent-specific email copy Copy is normalized for tone and clarity Email is sent (e.g. Gmail) Submission metadata is logged: Submission Completed Submission Timestamp Channel used Result Consistent, traceable outreach with CRM-style hygiene Data Analysis Purpose: Measure pipeline health and outreach effectiveness. Features Append-only decision and submission logs QuickChart visualizations for fast validation (e.g. TRUE vs FALSE completion rates) Optional integration with: Power BI Google Analytics 4 Supports Completion rate analysis Funnel tracking Source/platform performance Decision auditing Design Principles Separation of concerns** (ingestion ≠ decision ≠ outreach ≠ analytics) AI with hard guardrails** (strict schemas, source-only facts) Append-only logging** (analytics-safe, debuggable) Modular & extensible** (plug-and-play data sources) Human-readable + machine-usable outputs** Constraints & Notes Only public, professional information is used No private or speculative data HTTP scraping avoided unless necessary Power BI Embedded is not required Workflow designed and implemented end-to-end in ~3 days Use Cases Marketing Audience discovery Agent segmentation Personalization at scale Campaign readiness Funnel automation Sales Lead qualification Deduplication Outreach execution Status tracking Pipeline hygiene Tech Stack Automation:** n8n AI:** OpenAI (GPT) Scripting:** JavaScript Data Stores:** Google Sheets Email:** Gmail Visualization:** QuickChart BI (optional):** Power BI, Google Analytics 4 Cloud Sources:** AWS S3, Azure Blob, BigQuery Status This workflow is production-ready, modular, and designed for extension into other sales or marketing domains beyond literary outreach.
+2

Automate unified marketing reports with Google Analytics, Google Ads, Meta Ads & HubSpot

How it works This workflow runs on scheduled weekly and monthly triggers to generate unified marketing performance reports. It processes multiple websites by collecting analytics data, paid ads performance, and CRM leads, then calculates KPIs and insights automatically. The workflow sends structured reports via email and stores historical data in Google Sheets. It ensures consistent reporting without manual effort. Step-by-step Step 1: Trigger & report type detection** Schedule Trigger2 – Triggers the workflow weekly at a predefined time. Schedule Trigger3 – Triggers the workflow monthly at a predefined time. check month and week1 – Identifies whether the run is weekly or monthly and sets flags. Set Websites and Campaings1 – Defines websites, GA4 property IDs, and mapped ad campaigns. Expand Websites1 – Expands the website array into individual website items. Attach Run Flags1 – Attaches weekly or monthly flags to each website record. Step 2: Website & ads data processing** Loop Websites1 – Iterates through each website independently. Get a report – Fetches website traffic and engagement metrics from analytics. Get many campaigns – Retrieves Google Ads campaign data. Fetch Meta Ads – Fetches Meta Ads performance data via API. Filter Google Ads By Website1 – Filters Google Ads campaigns by website. Filter Meta Ads By Website1 – Filters Meta Ads campaigns by website. Merge1 – Merges analytics, Google Ads, and Meta Ads datasets. Build Website Dataset1 – Builds a unified dataset per website. Calculate KPIs & Campaign Insights1 – Calculates spend, CTR, CPA, CPL, conversions, and performance insights. Append or update row in sheet2 – Stores website-level marketing metrics in Google Sheets. Step 2.1: Marketing report generation** Prepare Report Data2 – Combines all website datasets into a unified report object. Switch – Routes execution based on weekly or monthly report type. Send Weekly Marketing report2 – Sends the weekly marketing performance email. Send Monthly Marketing Report2 – Sends the monthly marketing performance email. Step 3: HubSpot lead analysis** Fetch1 – Fetches leads from HubSpot CRM. Filter Hubspot Leads – Filters leads based on weekly or monthly time range. Summarize Hubspot Leads – Aggregates lead status and lifecycle metrics. Prepare Report Data3 – Prepares CRM summary data for reporting. Step 3.1: CRM reporting & storage** Switch3 – Routes CRM reporting by report type. Send Weekly Marketing report3 – Sends the weekly CRM summary email. Send Monthly Marketing Report3 – Sends the monthly CRM summary email. Code in JavaScript1 – Transforms CRM data for storage. Append or update row in sheet3 – Stores CRM lead performance data in Google Sheets. Switch3 – Routes CRM reporting by report type. Send Weekly Marketing report3 – Sends the weekly CRM summary email. Send Monthly Marketing Report3 – Sends the monthly CRM summary email. Code in JavaScript1 – Transforms CRM data for storage. Append or update row in sheet3 – Stores CRM lead performance data in Google Sheets. Why use this? Automates complex weekly and monthly marketing reporting. Unifies website analytics, ad platforms, and CRM data in one flow. Delivers consistent KPI calculations and insights every run. Maintains historical performance logs in Google Sheets. Scales easily across multiple websites and campaigns.

Weekly Google Analytics Report with GPT-4o Analysis & Email Delivery

Overview The workflow automatically gathers weekly user and page view metrics. It then uses AI to analyze, compare, and compile a summary report. Finally, it sends the report to the manager's email. How it works Get Data from GA Automatically retrieve data from Google Analytics (GA) for the two most recent weeks. Compare the data and calculate the variances between the two weeks. Generate Report Automatically analyze the data and generate reports using Artificial Intelligence (AI). Generate charts to visualize the data. Export the report to PDF. Send Report Send the report via email to the manager. Set up steps Google cloud account Create the credentials and replace them in the workflow. Please enable the following APIs: Gmail API Google Analytics Admin API Google Analytics Data API HTML to PDF account You need to install node HTML to PDF. Get API key and replace in the workflow.
+2

Marketing Analytics Reports with Google Analytics, Sheets, Slides & Email Alerts

Automate and Distribute Weekly and Monthly Marketing Analytics Reports Who's it for? This workflow is designed for marketing teams, data analysts, and business owners who need to consistently track key performance indicators (KPIs). It saves hours of manual data collection and reporting, ensuring stakeholders receive timely updates automatically. What it does This workflow automates the entire process of creating and distributing regular analytics reports. On a recurring weekly and monthly schedule, it: Fetches Data: Gathers the latest data from Google Analytics (users, sessions, conversions), your advertising platform (ad spend), and your CRM (new customers, revenue). Calculates KPIs: Processes the raw data to calculate essential business metrics, including Monthly Active Users (MAU), Customer Acquisition Cost (CAC), Lifetime Value (LTV), LTV:CAC ratio, and conversion rates. Logs Historical Data: Appends the newly calculated KPIs to a Google Sheet, creating a historical record for trend analysis. Generates a Report: Creates a new Google Slides presentation to serve as the main report. Distributes the Report: Emails a summary of the key metrics to a predefined list of recipients, including a link to the full Google Slides report. Provides Error Alerts: If any step in the process fails, it sends an immediate notification to a designated Slack channel so you can address the issue quickly. How to set up Configure Credentials: Add your credentials for Google Analytics, Google Sheets, Google Slides, Gmail, Slack, and the HTTP Request nodes (for your ad platform and CRM). Fill in Placeholders: In the "Workflow Configuration" node, replace all placeholder values with your specific information: gaPropertyId: Your Google Analytics Property ID. adPlatformApiUrl: The API endpoint for your advertising platform. crmApiUrl: The API endpoint for your CRM. reportSpreadsheetId: The ID of the Google Sheet where data will be stored. slidesTemplateId: The ID of your Google Slides report template. reportRecipients: A comma-separated list of email addresses for report distribution. slackChannel: The Slack channel ID for error notifications. Activate Workflow: Turn the workflow on. It will now run based on the schedule defined in the "Weekly/Monthly Schedule" trigger node. How to customize the workflow Adjust Schedule:** Modify the "Weekly/Monthly Schedule" node to change the reporting frequency (e.g., daily, bi-weekly). Change Reporting Period:** In the "Workflow Configuration" node, change the reportPeriodDays value to adjust the lookback window (e.g., set to 30 for a monthly report). Customize KPIs:** Edit the Javascript in the "Calculate KPIs (MAU, LTV, CAC)" node to add or modify metrics. Enhance the Report:** Expand the "Create Google Slides Report" node to dynamically add charts and data from the calculated KPIs into the slides.

Create a weekly LLM traffic report using Google Analytics, GPT-5, and Gmail

Overview Get a weekly report on website traffic driven by large language models (LLMs) such as ChatGPT, Perplexity, and Gemini. This workflow helps you track how these tools bring visitors to your site. A weekly snapshot can guide better content and marketing decisions. How it works The trigger runs every Monday. Pull the number of sessions on your website by source/medium from Google Analytics. The code node uses the following regex to filter referral traffic from AI providers like ChatGPT, Perplexity, and Gemini: /^.openai.|.copilot.|.chatgpt.|.gemini.|.gpt.|.neeva.|.writesonic.|.nimble.|.outrider.|.perplexity.|.google.bard.|.bard.google.|.bard.|.edgeservices.|.astastic.|.copy.ai.|.bnngpt.|.gemini.google.$/i; Combine the filtered sessions into one list so they can be processed by an LLM. Generate a short report using the filtered data. Email the report to yourself. Setup Get or connect your OpenAI API key and set up your OpenAI credentials in n8n. Enable Google Analytics and Gmail API access in the Google Cloud Console. (Read more here). Set up your Google Analytics and Gmail credentials in n8n. If you're using the cloud version of n8n, you can log in with your Google account to connect them easily. In the Google Analytics node, add your credentials and select the property for the website you’re working with. Alternatively, you can use your property ID, which can be found in the Google Analytics admin panel under Property > Property Details. The property ID is shown in the top-right corner. Add this to the property field. Under Metrics, select the metric you want to measure. This workflow is configured to use sessions, but you can choose others. Leave the dimension as-is, since we need the source/medium dimension to filter LLMs. (Optional) To expand the list of LLMs being filtered, adjust the regex in the code node. You can do this by copying and pasting one of the existing patterns and modifying it. Example: |.example.| The LLM node creates a basic report. If you’d like a more detailed version, adjust the system prompt to specify the details or formatting you want. Add your email address to the Gmail node so the report is delivered to your inbox. Requirements OpenAI API key for report generation Google Analytics API enabled in Google Cloud Console Gmail API enabled in Google Cloud Console Customizing this workflow The regex used to filter LLM referral traffic can be expanded to include specific websites. The system prompt in the AI node can be customized to create a more detailed or styled report.

Build your own Gmail and Google Analytics integration

Create custom Gmail and Google Analytics workflows by choosing triggers and actions. Nodes come with global operations and settings, as well as app-specific parameters that can be configured. You can also use the HTTP Request node to query data from any app or service with a REST API.

Gmail supported actions

Add Label
Delete
Get
Get Many
Mark as Read
Mark as Unread
Remove Label
Reply
Send
Send and Wait for Response
Create
Delete
Get
Get Many
Create
Delete
Get
Get Many
Add Label
Delete
Get
Get Many
Remove Label
Reply
Trash
Untrash

Google Analytics supported actions

Get
Return the analytics data
Search
Return user activity data

FAQs

  • Can Gmail connect with Google Analytics?

  • Can I use Gmail’s API with n8n?

  • Can I use Google Analytics’s API with n8n?

  • Is n8n secure for integrating Gmail and Google Analytics?

  • How to get started with Gmail and Google Analytics integration in n8n.io?

Need help setting up your Gmail and Google Analytics integration?

Discover our latest community's recommendations and join the discussions about Gmail and Google Analytics integration.
jake chard
Jan Koch
Paul Kennard

Looking to integrate Gmail and Google Analytics in your company?

Over 3000 companies switch to n8n every single week

Why use n8n to integrate Gmail with Google Analytics

Build complex workflows, really fast

Build complex workflows, really fast

Handle branching, merging and iteration easily.
Pause your workflow to wait for external events.

Code when you need it, UI when you don't

Simple debugging

Your data is displayed alongside your settings, making edge cases easy to track down.

Use templates to get started fast

Use 1000+ workflow templates available from our core team and our community.

Reuse your work

Copy and paste, easily import and export workflows.

Implement complex processes faster with n8n

red iconyellow iconred iconyellow icon