8
n8n 中文网amn8n.com

Google Search Console和Analytics分析与AI优化

高级

这是一个AI领域的自动化工作流,包含 29 个节点。主要使用 Set, Xml, Html, Sort, Wait 等节点,结合人工智能技术实现智能自动化。 Google Search Console和Analytics数据分析与AI优化

前置要求
  • 可能需要目标 API 的认证凭证
  • OpenAI API Key
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "Q0fs6FhvxUSO5kL4",
  "meta": {
    "instanceId": "bdce9ec27bbe2b742054f01d034b8b468d2e7758edd716403ad5bd4583a8f649",
    "templateCredsSetupCompleted": true
  },
  "name": "Google Search Console 和 Analytics 分析与 AI 优化",
  "tags": [],
  "nodes": [
    {
      "id": "4a4b478e-b5f8-4ddc-a6cc-48f1274cb5d6",
      "name": "点击“测试工作流”时",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -300,
        -300
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b52900dd-a2bd-42bb-8e1d-ce3cff259ec7",
      "name": "遍历项目",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        40,
        580
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "1ebe691b-6b76-4956-b181-c2be251d48be",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        480
      ],
      "parameters": {
        "width": 1620,
        "height": 640,
        "content": "## 获取 Google 数据并通过 AI 处理"
      },
      "typeVersion": 1
    },
    {
      "id": "7194a576-50ab-4df0-b6db-d6a74bcbb927",
      "name": "强制执行顺序 - 最后处理位置",
      "type": "n8n-nodes-base.merge",
      "position": [
        280,
        260
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "be892b2b-6141-415c-a503-d4f7d467cc6a",
      "name": "移除重复项",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        940,
        -60
      ],
      "parameters": {
        "compare": "selectedFields",
        "options": {},
        "fieldsToCompare": "loc"
      },
      "typeVersion": 2
    },
    {
      "id": "ebb767ad-a8db-449a-8d52-56731248e9e5",
      "name": "便签 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -140
      ],
      "parameters": {
        "width": 880,
        "height": 320,
        "content": "## 从站点地图获取所有页面"
      },
      "typeVersion": 1
    },
    {
      "id": "d421db5a-c224-44ef-a471-d64ca8ddaa69",
      "name": "获取站点地图 XML",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        280,
        -60
      ],
      "parameters": {
        "url": "={{ $('Globals - CHANGE ME!').item.json.sitemap_url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "6bf0e08e-1cfa-4484-b953-cd215447d053",
      "name": "转换为 JSON",
      "type": "n8n-nodes-base.xml",
      "position": [
        500,
        -60
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "b5ab24fc-8c0f-4158-9452-35fc682246ff",
      "name": "拆分到表格",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        720,
        -60
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "urlset.url"
      },
      "typeVersion": 1
    },
    {
      "id": "81c644b2-1de8-4f51-be73-ac2246fb3c5f",
      "name": "用于测试的限制",
      "type": "n8n-nodes-base.limit",
      "position": [
        1400,
        -60
      ],
      "parameters": {
        "maxItems": 5
      },
      "typeVersion": 1
    },
    {
      "id": "77c271b5-99b9-4adf-8b7f-7dc0846325bd",
      "name": "等待以遵守 API 限制",
      "type": "n8n-nodes-base.wait",
      "position": [
        900,
        500
      ],
      "webhookId": "51b5aeba-6be7-45d4-97fd-4e5cb5a8401b",
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "00b83323-17ef-44a1-82b1-eb867e532556",
      "name": "全局变量 - 请修改我!",
      "type": "n8n-nodes-base.set",
      "position": [
        40,
        -60
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "be81885f-3f27-4edd-985d-8dd98908a197",
              "name": "sitemap_url",
              "type": "string",
              "value": "https://sailingbyte.com/sitemap.xml"
            },
            {
              "id": "c1f4c9ba-9222-4757-a89e-0d67af1d3944",
              "name": "search_console_selector",
              "type": "string",
              "value": "sc-domain:example.com"
            },
            {
              "id": "9c57f9cc-1e94-4174-b622-7533c7776bee",
              "name": "analysis_start_date",
              "type": "string",
              "value": "={{ $now.minus(30,'days').format('yyyy-MM-dd') }}"
            },
            {
              "id": "51dd8171-2300-4574-9c71-56793127bf4a",
              "name": "analysis_end_date",
              "type": "string",
              "value": "={{ $now.format('yyyy-MM-dd') }}"
            },
            {
              "id": "5e09cf25-80d9-44fe-9cf3-e2517bcfc6e6",
              "name": "analytics_selector_id",
              "type": "number",
              "value": 0
            },
            {
              "id": "5befd844-afe6-44c9-8ecd-c2741d838b19",
              "name": "report_receiver",
              "type": "string",
              "value": "email@eamil.com"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cde1f4e7-f45d-4c64-906e-3b191550fc9a",
      "name": "获取页面 GSC 状态",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        280,
        560
      ],
      "parameters": {
        "url": "https://searchconsole.googleapis.com/v1/urlInspection/index:inspect",
        "method": "POST",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "inspectionUrl",
              "value": "={{ $json.loc }}"
            },
            {
              "name": "siteUrl",
              "value": "={{ $('Globals - CHANGE ME!').first().json.search_console_selector }}"
            }
          ]
        },
        "nodeCredentialType": "googleOAuth2Api"
      },
      "credentials": {
        "googleOAuth2Api": {
          "id": "wWLEdLgRqrkoJMke",
          "name": "Google account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "c4856013-3111-4c04-b4d2-f92ad8f1cd88",
      "name": "获取页面 GSC 统计信息",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        280,
        740
      ],
      "parameters": {
        "url": "=https://www.googleapis.com/webmasters/v3/sites/{{ $('Globals - CHANGE ME!').first().json.search_console_selector }}/searchAnalytics/query",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"startDate\": \"{{ $('Globals - CHANGE ME!').first().json.analysis_start_date }}\",\n  \"endDate\": \"{{ $('Globals - CHANGE ME!').first().json.analysis_end_date }}\",\n  \"type\": \"web\",\n  \"dimensionFilterGroups\": [\n    {\n      \"groupType\": \"AND\",\n      \"filters\": [\n        {\n          \"dimension\": \"page\",\n          \"operator\": \"contains\",\n          \"expression\": \"{{ $json.loc }}\"\n        }\n      ]\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleOAuth2Api"
      },
      "credentials": {
        "googleOAuth2Api": {
          "id": "wWLEdLgRqrkoJMke",
          "name": "Google account"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "b5e8f02d-320c-4fab-9e38-2a6dbb97e7b1",
      "name": "合并状态和统计信息",
      "type": "n8n-nodes-base.merge",
      "position": [
        540,
        680
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "c7ff4009-65be-4d4a-b3dd-f711e7cefebb",
      "name": "OpenAI 聊天模型",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        660,
        880
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "o4-mini",
          "cachedResultName": "o4-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "zjIZQuuuZMJpiUny",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "133cbc78-a835-4d6c-a366-187d3f2ca4b1",
      "name": "获取 Google Analytics 数据",
      "type": "n8n-nodes-base.googleAnalytics",
      "position": [
        280,
        920
      ],
      "parameters": {
        "endDate": "={{ $('Globals - CHANGE ME!').first().json.analysis_end_date }}",
        "dateRange": "custom",
        "returnAll": true,
        "startDate": "={{ $('Globals - CHANGE ME!').first().json.analysis_start_date }}",
        "metricsGA4": {
          "metricValues": [
            {},
            {
              "listName": "screenPageViews"
            },
            {
              "listName": "userEngagementDuration"
            }
          ]
        },
        "propertyId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Globals - CHANGE ME!').first().json.analytics_selector_id }}"
        },
        "dimensionsGA4": {
          "dimensionValues": [
            {
              "listName": "pageLocation"
            }
          ]
        },
        "additionalFields": {
          "dimensionFiltersUI": {
            "filterExpressions": {
              "expression": {
                "stringFilter": [
                  {
                    "value": "={{ $json.loc }}",
                    "listName": "pageLocation",
                    "caseSensitive": false
                  }
                ]
              }
            }
          }
        }
      },
      "credentials": {
        "googleAnalyticsOAuth2": {
          "id": "4JVj7vMgAo09ILvS",
          "name": "Google Analytics account"
        }
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "fc55254f-012b-4387-af4c-54211b386182",
      "name": "HTTP 请求",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        940,
        880
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', ``, 'string') }}",
        "options": {},
        "toolDescription": "Make HTTP request to get page data so you can further analyze page for SEO optimizations"
      },
      "typeVersion": 4.2
    },
    {
      "id": "3658c627-a22b-4f4c-b2ee-33e9a361bb1e",
      "name": "将 AI 输出与 AI 输入合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        1400,
        900
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "b92d08c4-13a3-4c92-b37f-da3a7a5ee7dc",
      "name": "Markdown 转 HTML",
      "type": "n8n-nodes-base.markdown",
      "position": [
        1120,
        900
      ],
      "parameters": {
        "mode": "markdownToHtml",
        "options": {},
        "markdown": "={{ $json.output }}",
        "destinationKey": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "a77ef66d-1313-43ee-b23f-c23a24529026",
      "name": "仅保留有价值的列",
      "type": "n8n-nodes-base.set",
      "position": [
        500,
        260
      ],
      "parameters": {
        "options": {
          "dotNotation": false,
          "ignoreConversionErrors": true
        },
        "assignments": {
          "assignments": [
            {
              "id": "6a86e547-b789-4319-886f-b06120967d64",
              "name": "loc",
              "type": "string",
              "value": "={{ $json.loc }}"
            },
            {
              "id": "8ba00cd3-e45a-439f-b703-8a42dd0628fa",
              "name": "inspectionResult.indexStatusResult.coverageState",
              "type": "string",
              "value": "={{ $json.inspectionResult.indexStatusResult.coverageState }}"
            },
            {
              "id": "b83dc435-cbb1-4dc3-8c7e-3af41201dbfe",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fad58242-29c7-4c48-ae3f-667559cfd644",
      "name": "更改为 HTML 表格以便发送",
      "type": "n8n-nodes-base.html",
      "position": [
        720,
        260
      ],
      "parameters": {
        "options": {},
        "operation": "convertToHtmlTable"
      },
      "typeVersion": 1.2
    },
    {
      "id": "3d737f97-9d5c-4f0c-8a2a-cbe98e0879d2",
      "name": "发送包含完整报告的电子邮件",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        940,
        260
      ],
      "webhookId": "843191c3-c853-43c1-9523-4661654fb58e",
      "parameters": {
        "html": "=<h2>Analysis is complete</h2>\n{{ $json.table }}\n\n",
        "options": {},
        "subject": "Your Analysis Is Complete",
        "toEmail": "={{ $('Globals - CHANGE ME!').first().json['report_receiver'] }}",
        "fromEmail": "={{ $('Globals - CHANGE ME!').first().json['report_receiver'] }}"
      },
      "credentials": {
        "smtp": {
          "id": "tkdzDgcUAt04af3B",
          "name": "SMTP account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "8888143f-73ed-4ac7-84ee-b5b4bcf64c6e",
      "name": "为测试目的排序",
      "type": "n8n-nodes-base.sort",
      "position": [
        1180,
        -60
      ],
      "parameters": {
        "type": "random"
      },
      "typeVersion": 1
    },
    {
      "id": "fd4431b6-8a0a-4a2b-a70b-17d3fc2f34b5",
      "name": "便签 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1140,
        -140
      ],
      "parameters": {
        "color": 6,
        "width": 440,
        "height": 320,
        "content": "## 用于测试的限制"
      },
      "typeVersion": 1
    },
    {
      "id": "b821114e-234c-4183-a957-d5048f366ecd",
      "name": "便签 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        -140
      ],
      "parameters": {
        "color": 4,
        "height": 320,
        "content": "## 首先设置我"
      },
      "typeVersion": 1
    },
    {
      "id": "2e0a5df7-7dd1-4ca7-b9e7-763928b32913",
      "name": "便签 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        200
      ],
      "parameters": {
        "color": 3,
        "width": 1340,
        "height": 260,
        "content": "## 获取电子邮件报告"
      },
      "typeVersion": 1
    },
    {
      "id": "a16024d1-28a1-4b73-85b7-fc15e9620184",
      "name": "便签 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -140
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 320,
        "content": "- sitemap_url - 不言自明"
      },
      "typeVersion": 1
    },
    {
      "id": "cd5d0d57-f04a-4094-8f26-855dd1051589",
      "name": "SEO 分析师",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        780,
        680
      ],
      "parameters": {
        "text": "=You are professional SEO analyst and improver. You will receive in input data from Google Analytics and Google Search Console. Delivered data will be for single page.\n\nBased on this data, your task is to propose improvements, that are very specific to this page, and which will impact this web page positively. \n\nGeneral Data Evaluation:\n- How to get more users on this specific page\n- How to engage users more on this specific page\n- Analyze page itself for improvements\n- Look for potential issues in Google Analytics and Google Search Console data\n- Look for potential issues on website itself\n\nTechnical Evaluation:\n- Critical Fixes – Issues requiring immediate attention and resolution.\n- High-Impact Solutions – Simple adjustments that deliver significant results.\n- Enhancement Possibilities – Initiatives demanding greater investment but providing valuable long-term gains.\n\nContent Evaluation:\n- Keyword Strategy Assessment – Determine core and supporting search terms, evaluate keyword concentration levels, and examine strategic keyword positioning throughout the content.\n- Content Quality Review – Analyze the material's comprehensiveness, precision, and alignment with intended audience needs and expectations.\n- Accessibility and Clarity Analysis – Measure content comprehension difficulty through established readability frameworks including Flesch-Kincaid educational level, Flesch Reading Ease score, and Gunning-Fog complexity index.\n\nYou can add other improvement ideas, but they must be very specific to given page, no generalizations.\n\nWebsite is: {{ $json.pageLocation }}\n\nGoogle Analytics data is:\n- total users: {{ $json.totalUsers ?? 0}}\n- screen page views: {{ $json.screenPageViews ?? 0 }}\n- user engagement duration: {{ $json.userEngagementDuration ?? 0 }}\n\nGoogle Search Console data is:\n{{ $json.rows[0].toJsonString() }}\n\nIndexing status is as follows:\n{{ $json.inspectionResult.toJsonString() }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "5",
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveDataSuccessExecution": "all"
  },
  "versionId": "dc23ed85-f60d-4a41-b7c1-19cd5ac272b4",
  "connections": {
    "SEO analyst": {
      "main": [
        [
          {
            "node": "Markdown to HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "ai_tool": [
        [
          {
            "node": "SEO analyst",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Convert to JSON": {
      "main": [
        [
          {
            "node": "Split Out to Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get sitemap XML": {
      "main": [
        [
          {
            "node": "Convert to JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Enforce Order - Positions Last",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Get Page GSC Status",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Page GSC Stats",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Google Analytics Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown to HTML": {
      "main": [
        [
          {
            "node": "Merge AI Output With AI Input",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "SEO analyst",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates": {
      "main": [
        [
          {
            "node": "Sort For Testing Purposes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Page GSC Stats": {
      "main": [
        [
          {
            "node": "Merge Status and Stats",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Split Out to Table": {
      "main": [
        [
          {
            "node": "Remove Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Page GSC Status": {
      "main": [
        [
          {
            "node": "Merge Status and Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Globals - CHANGE ME!": {
      "main": [
        [
          {
            "node": "Get sitemap XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Status and Stats": {
      "main": [
        [
          {
            "node": "SEO analyst",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wait to Comply with API Limits",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Google Analytics Data": {
      "main": [
        [
          {
            "node": "Merge Status and Stats",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Sort For Testing Purposes": {
      "main": [
        [
          {
            "node": "Limit for Testing Purposes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep Only Valuable Columns": {
      "main": [
        [
          {
            "node": "Change to HTML table for sending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit for Testing Purposes": {
      "main": [
        [
          {
            "node": "Enforce Order - Positions Last",
            "type": "main",
            "index": 0
          },
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge AI Output With AI Input": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enforce Order - Positions Last": {
      "main": [
        [
          {
            "node": "Keep Only Valuable Columns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait to Comply with API Limits": {
      "main": [
        [
          {
            "node": "Merge AI Output With AI Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Change to HTML table for sending": {
      "main": [
        [
          {
            "node": "Send Email with Full report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking ‘Test workflow’": {
      "main": [
        [
          {
            "node": "Globals - CHANGE ME!",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量29
分类1
节点类型19
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Łukasz

Łukasz

@lukaszpp

Developer, automation enthusiast and dedicated CTO/CEO

外部链接
在 n8n.io 查看

分享此工作流