Automate SEO Analysis with Google Analytics & n8n AI

This workflow automates the comparison of weekly Google Analytics SEO data and leverages AI to provide actionable SEO improvement suggestions. It saves hours of manual analysis by processing engagement, search console, and country views data into digestible AI-generated reports.
googleAnalytics
httpRequest
code
+4
Workflow Identifier: 2208
NODES in Use: scheduleTrigger, manualTrigger, stickyNote, googleAnalytics, code, httpRequest, baserow
Automate SEO with Google Analytics and n8n

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Workflow Does

This workflow gets your Google Analytics and Search Console data for two weeks.

It compares this week and last week on page views, user activity, and countries.

It sends these details to an AI model to get simple SEO ideas.

Finally, it saves AI reports to a Baserow table to keep history.

It saves you about 5 hours of manual work each week.


Tools and Services Used

  • Google Analytics GA4: supplies web traffic and engagement data.
  • Google Search Console: provides search performance data.
  • OpenRouter API: access Meta LLaMA AI for SEO suggestions.
  • Baserow: stores AI generated SEO reports.
  • n8n: builds and runs the automation workflow.

Inputs, Processing, and Output

Inputs

  • Google Analytics GA4 property ID and OAuth2 credentials.
  • OpenRouter API key for AI access.
  • Baserow API key and table for report storage.

Processing Steps

  • Fetch current and prior week page engagement metrics from Google Analytics.
  • Fetch current and prior week search and country data from Google Search Console and GA.
  • Use Code nodes with JavaScript to parse and format this complex data into simple JSON strings.
  • Send parsed data with prompts to AI via HTTP Request nodes using OpenRouter.
  • Receive SEO suggestions and markdown summaries from AI.
  • Save AI results to Baserow database for future reference.

Output

Markdown tables showing trends and SEO improvement ideas.

Stored reports in Baserow for tracking over time.


Who Should Use This Workflow

People managing website SEO but not wanting to spend hours gathering analytics.

Users who want easy-to-understand SEO advice turned from raw data.

Anyone automating weekly SEO reporting without deep coding skills.


Beginner Step-by-Step: How to Use This Workflow in Production

Step 1: Download and Import Workflow

  1. Click the Download button on this page to get the workflow file.
  2. Inside your n8n editor, use the menu to “Import from File” and select the downloaded workflow.

Step 2: Configure Credentials and IDs

  1. Open the Google Analytics nodes and enter your GA4 property ID.
  2. Set up Google Analytics OAuth2 credentials in n8n and select them in these nodes.
  3. Open the HTTP Request nodes and add your OpenRouter API Key in the Authorization header.
  4. Update Baserow API key in the Baserow node and confirm the correct table and column names.

Step 3: Adjust Code or Prompt If Needed

  1. Copy-paste or edit JavaScript in the Code nodes if your data structure changes.
  2. Modify the AI prompt text in HTTP Request nodes if different SEO questions are wanted.

Step 4: Test the Workflow Once

  1. Run the workflow manually from the Manual Trigger.
  2. Check node outputs step-by-step for data correctness.
  3. Confirm Baserow entry creation with AI data.

Step 5: Activate Workflow for Production

  1. Turn on the workflow.
  2. If desired, enable the Schedule Trigger to run weekly automatically.
  3. Monitor the logs in n8n to catch errors early.

If using self-host n8n this works the same; see self-host n8n for help setting it up.


Code Snippet Example for Parsing Data

This code simplifies the raw GA4 JSON response to key values for AI input.

function transformToUrlString(items) {
  const analyticsData = items[0].json;
  const simplified = analyticsData.rows.map(row => ({
    page: row.dimensionValues[0].value,
    pageViews: parseInt(row.metricValues[0].value) || 0,
    activeUsers: parseInt(row.metricValues[1].value) || 0,
    viewsPerUser: parseFloat(row.metricValues[2].value) || 0,
    eventCount: parseInt(row.metricValues[3].value) || 0
  }));
  return encodeURIComponent(JSON.stringify(simplified));
}
const urlString = transformToUrlString($input.all());
return { json: { urlString } };

Customizations

  • Change AI Model or Prompt Text
    Edit the HTTP Request nodes to use different AI models or adjust SEO question prompts.
  • Include More GA Metrics
    Add session duration or bounce rate metrics in GA nodes and update parsing code accordingly.
  • Change Schedule Frequency
    Modify the Schedule Trigger node to run the workflow daily or monthly.
  • Add Email Notifications
    Insert an email sending node to send SEO reports directly after AI generates them.
  • Adjust Baserow Table Layout
    Change or add columns for extra insights or date aggregations.

Common Issues and Fixes

  • Empty Data from Google Analytics
    Check GA4 property ID correctness and refresh OAuth2 credentials in n8n.
  • AI API Calls Fail
    Verify OpenRouter API URL and Authorization header with correct API Key.
  • Code Node Parsing Errors
    Test GA nodes output separately to confirm the structure. Update parsing code for missing fields.
  • Baserow Save Fails
    Confirm Baserow API key and exact table and column names match those in the workflow.

Summary of Benefits

✓ Saves 5+ hours weekly by automating Google Analytics and Search Console data gathering.

✓ Provides clear, AI-generated SEO suggestions in markdown tables.

✓ Keeps historical SEO insight records in Baserow database.

→ Simplifies complex data into easy actions for SEO teams.


Automate SEO with Google Analytics and n8n

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Yes, edit the model name inside the HTTP Request nodes to use supported AI models.
Incorrect GA4 property ID or expired OAuth2 credentials usually cause empty data.
Check that Google Analytics nodes return expected JSON with metric and dimension rows, then update code to handle nulls.
Yes, credentials and API keys are stored securely within n8n; do not share keys publicly.
Author
Written By
Vikash Kumar
Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.