8
n8n 中文网amn8n.com

使用 Google Sheets 查询每日监控排名

中级

这是一个Market Research领域的自动化工作流,包含 12 个节点。主要使用 Set, Code, SplitOut, GoogleSheets, ScheduleTrigger 等节点。 使用 DataForSEO 和 Google Sheets 跟踪每日 SEO 排名

前置要求
  • Google Sheets API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "vcSpTA8efH86xwYi",
  "meta": {
    "instanceId": "c24388df44432e8ff2c4acecd7ab0dd2faec628bd83c70beb384cea105f7a50a",
    "templateCredsSetupCompleted": true
  },
  "name": "使用 Google Sheets 查询每日监控排名",
  "tags": [
    {
      "id": "RhAmCaLYc9EkF42I",
      "name": "n8n",
      "createdAt": "2025-08-24T08:04:35.027Z",
      "updatedAt": "2025-08-24T08:04:35.027Z"
    }
  ],
  "nodes": [
    {
      "id": "12b77eba-974e-438f-bed3-d282010a51fe",
      "name": "计划触发器",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -120,
        -180
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 8
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "30693f14-7ea0-41e9-8a55-70279c1ff4c9",
      "name": "拆分输出",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        60,
        260
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "tasks[0].result"
      },
      "typeVersion": 1
    },
    {
      "id": "8700a445-a671-4ccf-ab5d-b49581999bc2",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        -560
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 720,
        "content": "## 📄 **获取关键词列表(Google Sheets)**"
      },
      "typeVersion": 1
    },
    {
      "id": "74506eb2-5e79-46a7-b484-00041afe6743",
      "name": "获取关键词列表(Google Sheets)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        220,
        -40
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ShdLc4td6MSQf49l4tDlVohRlFxNO0SdkG0bHQ5LJmE/edit#gid=0",
          "cachedResultName": "queries"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ShdLc4td6MSQf49l4tDlVohRlFxNO0SdkG0bHQ5LJmE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ShdLc4td6MSQf49l4tDlVohRlFxNO0SdkG0bHQ5LJmE/edit?usp=drivesdk",
          "cachedResultName": "Daily Monitor Position | n8n"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "A3ebjIB2M27srsju",
          "name": "Nima40"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "bed29055-a0f1-4739-b65b-6d8b612e39f0",
      "name": "获取 SERP 数据(DataForSEO API)",
      "type": "n8n-nodes-dataforseo.dataForSeo",
      "position": [
        660,
        0
      ],
      "parameters": {
        "depth": 10,
        "keyword": "={{ $json.query }}",
        "resource": "serp",
        "language_name": "English",
        "location_name": "United States"
      },
      "credentials": {
        "dataForSeoApi": {
          "id": "GxoHZ00Kb6B5qP12",
          "name": "DataForSEO account"
        }
      },
      "executeOnce": false,
      "typeVersion": 1
    },
    {
      "id": "73c65e58-ed21-4c88-8abf-7ec37b61c38b",
      "name": "提取查询、排名和域名",
      "type": "n8n-nodes-base.code",
      "position": [
        280,
        260
      ],
      "parameters": {
        "jsCode": "// Get all DataForSEO results\nconst results = $input.all();\n\n// Prepare flattened array\nconst rows = [];\n\nfor (const res of results) {\n  const keyword = res.json.keyword;\n  const items = res.json.items || [];\n\n  for (const item of items) {\n    // Only take organic results\n    if (item.type === \"organic\") {\n      rows.push({\n        query: keyword,\n        rank: item.rank_group,\n        domain: item.domain\n      });\n    }\n  }\n}\n\n// Output flattened array for next node (Google Sheets)\nreturn rows.map(r => ({ json: r }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "3d158ce9-c0a5-47bf-92b8-b41c4bb71b0a",
      "name": "添加时间戳并准备输出",
      "type": "n8n-nodes-base.set",
      "position": [
        500,
        260
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "563b4310-e127-4dea-905b-dcbc7c6236d2",
              "name": "query",
              "type": "string",
              "value": "={{ $json.query }}"
            },
            {
              "id": "ccbaa0ef-229a-447e-b524-5cf096a98cc9",
              "name": "rank",
              "type": "string",
              "value": "={{ $json.rank }}"
            },
            {
              "id": "1b6d2b30-9118-41b7-982d-67e2e89cd668",
              "name": "domain",
              "type": "string",
              "value": "={{ $json.domain }}"
            },
            {
              "id": "9718ada3-6127-4c73-8653-590fc99e88b2",
              "name": "date",
              "type": "string",
              "value": "={{ new Date().toISOString().split('T')[0] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d21074e7-2552-42c7-816b-79da4e9960fa",
      "name": "将结果追加到 Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        740,
        560
      ],
      "parameters": {
        "columns": {
          "value": {
            "date": "={{ $json.date }}",
            "rank": "={{ $json.rank }}",
            "query": "={{ $json.query }}",
            "domain": "={{ $json.domain }}"
          },
          "schema": [
            {
              "id": "query",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rank",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "domain",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "domain",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1022700330,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ShdLc4td6MSQf49l4tDlVohRlFxNO0SdkG0bHQ5LJmE/edit#gid=1022700330",
          "cachedResultName": "rank"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ShdLc4td6MSQf49l4tDlVohRlFxNO0SdkG0bHQ5LJmE",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ShdLc4td6MSQf49l4tDlVohRlFxNO0SdkG0bHQ5LJmE/edit?usp=drivesdk",
          "cachedResultName": "Daily Monitor Position | n8n"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "A3ebjIB2M27srsju",
          "name": "Nima40"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "f14d433f-4a51-4bf7-95fa-a616a788e4d5",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -400
      ],
      "parameters": {
        "color": 5,
        "width": 280,
        "height": 400,
        "content": "## 🕒 **每日计划触发器**"
      },
      "typeVersion": 1
    },
    {
      "id": "5aeafcc6-98e9-4cd8-8c66-184ebb882cc0",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        500,
        -560
      ],
      "parameters": {
        "color": 5,
        "width": 440,
        "height": 720,
        "content": "## 🔍 **获取 SERP 数据(DataForSEO API)**"
      },
      "typeVersion": 1
    },
    {
      "id": "61d504d9-512b-4aa9-acfc-6b257c6e5fbd",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        40,
        440
      ],
      "parameters": {
        "color": 5,
        "width": 900,
        "height": 300,
        "content": "## 📊 **将结果追加到 Google Sheet**"
      },
      "typeVersion": 1
    },
    {
      "id": "ecbc3949-16b9-4291-9e98-8c7e6c18d33d",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        980,
        280
      ],
      "parameters": {
        "color": 4,
        "width": 780,
        "height": 460,
        "content": "## 📋 **示例输出(Google Sheet)**"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5413dda5-1d8f-4d68-9322-f5e8fd06be69",
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "Extract Query, Rank & Domain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Fetch Keyword List (Google Sheets)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Query, Rank & Domain": {
      "main": [
        [
          {
            "node": "Add Timestamp & Prepare Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add Timestamp & Prepare Output": {
      "main": [
        [
          {
            "node": "Append Results to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch SERP Data (DataForSEO API)": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Keyword List (Google Sheets)": {
      "main": [
        [
          {
            "node": "Fetch SERP Data (DataForSEO API)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

中级 - 市场调研

需要付费吗?

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

工作流信息
难度等级
中级
节点数量12
分类1
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Nima Salimi

Nima Salimi

@salimi

- Marketing Automation Specialist - Marketing Workflow Architect - Optimizing Marketing Processes

外部链接
在 n8n.io 查看

分享此工作流