{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "29f876d8-6376-4c30-b090-d98e0b19efb7",
      "name": "NocoDB1",
      "type": "n8n-nodes-base.nocoDb",
      "position": [
        1060,
        160
      ],
      "parameters": {
        "table": "muc0kmjqos1invc",
        "operation": "create",
        "projectId": "p97b9jham4uh16u",
        "dataToSend": "autoMapInputData",
        "workspaceId": "wko8iu8c",
        "authentication": "nocoDbApiToken"
      },
      "credentials": {
        "nocoDbApiToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "adbf93b4-0174-41b0-a4b3-b38407df2d1e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 260.6598393933048,
        "height": 313.71656632131885,
        "content": "\ud83d\udccc Node: Schedule Trigger\nRuns the automation on a fixed schedule (e.g., daily). Used to trigger SEO data collection from Google Search Console automatically."
      },
      "typeVersion": 1
    },
    {
      "id": "f4c79269-74dd-4918-b7a8-bb5b22b8af57",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 260.6598393933048,
        "height": 313.71656632131885,
        "content": "\ud83d\udccc  Node: HTTP Request\nMakes a POST request to GSC API (Search Analytics endpoint). Authenticated with OAuth2. Retrieves performance data like clicks, impressions, CTR."
      },
      "typeVersion": 1
    },
    {
      "id": "536e2048-dcf5-4309-90d6-62de2a26cc8f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 260.6598393933048,
        "height": 313.71656632131885,
        "content": "\ud83d\udccc Node: Code\nParses and restructures the raw GSC API response. Extracts fields like query, page, date, device, clicks, CTR, and position for database insertion.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9f1cda9a-97c5-499d-836a-a7b69a4af6a5",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        980,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 260.6598393933048,
        "height": 313.71656632131885,
        "content": "\n\ud83d\udccc Node: NocoDB1 (create: row)\nPushes parsed SEO data into NocoDB (`gsc_data` table). This builds a structured, queryable database of daily SEO performance.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b56613ed-ffb0-4082-90ce-b748ee58abfc",
      "name": "Schedule Trigger1",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        80,
        160
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 1
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9ebb1a98-4913-496f-9f97-b57886d01bc7",
      "name": "HTTP Request1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        400,
        160
      ],
      "parameters": {
        "url": "https://searchconsole.googleapis.com/webmasters/v3/sites/sc-domain:martechmafia.net/searchAnalytics/query",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"startDate\": \"{{ new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0] }}\",\n  \"endDate\": \"{{ new Date().toISOString().split('T')[0] }}\",\n  \"dimensions\": [\"query\", \"page\", \"device\", \"date\"],\n  \"rowLimit\": 1000\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleOAuth2Api"
      },
      "credentials": {
        "googleOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e65f93e1-715d-451a-b205-7c1c2ff1f6ca",
      "name": "Code1",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        160
      ],
      "parameters": {
        "jsCode": "return $json.rows.map(row => ({\n  json: {\n    date: row.keys[3],\n    query: row.keys[0],\n    page: row.keys[1],\n    device: row.keys[2],\n    clicks: row.clicks,\n    impressions: row.impressions,\n    ctr: row.ctr,\n    position: row.position\n  }\n}));"
      },
      "typeVersion": 2
    }
  ],
  "connections": {
    "Code1": {
      "main": [
        [
          {
            "node": "NocoDB1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger1": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}