{
  "nodes": [
    {
      "id": "4ba10d81-f58d-49db-be31-8c4c870dec1d",
      "name": "Global Storage",
      "type": "n8n-nodes-base.set",
      "position": [
        -1220,
        20
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "6d160d8b-ab11-4f0a-a484-2e3f8f7f3033",
              "name": "website",
              "type": "string",
              "value": "={{ $json.Website }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "bd802aa0-ade4-4265-949b-b5ce7cea6293",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -560,
        40
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3ec0a058-9e37-4363-a4da-b7937144be13",
              "operator": {
                "type": "object",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.data }}",
              "rightValue": ""
            },
            {
              "id": "425822e3-7fd3-4758-a84d-7a2d11fcaad4",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.semrushAPI.organicCompetitors }}",
              "rightValue": ""
            },
            {
              "id": "b073fc07-7831-4715-9d45-ac37229241bb",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.semrushAPI.organicPages }}",
              "rightValue": ""
            },
            {
              "id": "cf43ccec-f2a5-4ea5-8394-b99710f9e6e4",
              "operator": {
                "type": "array",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.semrushAPI.domainOrganicSearchKeywords }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3254616f-6f6b-4b81-bc9d-056dd8599a94",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        -200,
        220
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "ef80c50c-a2b8-47d4-ab0b-47b3f4cca7a3",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -1480,
        20
      ],
      "parameters": {
        "options": {},
        "formTitle": "Competitor Analysis",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Website",
              "placeholder": "e.g. instagram.com",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Enter website domain to check competitor"
      },
      "typeVersion": 2.2
    },
    {
      "id": "737f5a72-18fb-48f7-9532-471fc19f39eb",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -200,
        -180
      ],
      "parameters": {
        "columns": {
          "value": {
            "Domain": "={{ $('Global Storage').item.json.website }}",
            "Organic Page": "={{ $json.data.semrushAPI.organicPages }}",
            "Organic competitor": "={{ $json.data.semrushAPI.organicCompetitors }}",
            "Domain organic search": "={{ $json.data.semrushAPI.domainOrganicSearchKeywords }}"
          },
          "schema": [
            {
              "id": "Domain",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Domain",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Organic competitor",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Organic competitor",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Organic Page",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Organic Page",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Domain organic search",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Domain organic search",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "9b807b33-2f49-4d58-9fc9-2ff9e14d7439",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        260,
        200
      ],
      "parameters": {
        "columns": {
          "value": {
            "Domain": "={{ $('Global Storage').item.json.website }}",
            "Organic Page": "=Not data found.",
            "Organic competitor": "=Not data found.",
            "Domain organic search": "=Not data found."
          },
          "schema": [
            {
              "id": "Domain",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Domain",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Organic competitor",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Organic competitor",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Organic Page",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Organic Page",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Domain organic search",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Domain organic search",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "f4d9cc87-fdbb-4842-a9b4-19bb799444fd",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1540,
        -140
      ],
      "parameters": {
        "width": 220,
        "height": 320,
        "content": "### 1. \ud83d\udfe2 **On form submission**\n**Type:** `formTrigger`  \n**Description:** Triggers when a user submits the form with `Website` fields.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "827c2ee8-778c-4823-a3cb-760d0261d3c3",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1280,
        -140
      ],
      "parameters": {
        "height": 320,
        "content": "### 2. \ud83d\udce6 **Global Storage**\n**Type:** `set`  \n**Description:** Stores the website value from the form for use in later nodes.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "16a60929-44a8-4521-8a41-bf0db993fe5c",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1000,
        -140
      ],
      "parameters": {
        "width": 300,
        "height": 340,
        "content": "### 3. \ud83c\udf10 **Competitor Analysis Request**\n**Type:** `httpRequest`  \n**Description:** Sends a POST request to the RapidAPI Competitor Analysis endpoint (`competitor.php`) to get broad match competitors insights.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8c8ed73b-427b-4c62-9eac-80743d518ce2",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -660,
        -160
      ],
      "parameters": {
        "width": 300,
        "height": 340,
        "content": "### 4. \u2696\ufe0f **Condition Checking**\n**Type:** `if`  \n**Description:** Evaluates whether the response body contains non-empty data. If true, it proceeds down the \"true\" branch, otherwise it moves to the \"false\" branch for further actions. Ideal for handling conditional logic in workflows.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "90e85218-3e39-4cb2-b175-7eb6fb681b7a",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        20
      ],
      "parameters": {
        "width": 360,
        "height": 340,
        "content": "### 6. \u23f3 **Wait Node (5-Second Interval)**\n**Type:** `wait`  \n**Description:** Introduces a 5-second delay in the workflow before moving to the next action. Ideal for controlling the flow of execution, pacing API calls, or ensuring sufficient time between operations.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b834649d-3233-402e-955c-a2813b041c3f",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -520
      ],
      "parameters": {
        "width": 360,
        "height": 500,
        "content": "### 5. \ud83d\udcca **Google Sheets - Insert Record from Response Body**\n**Type:** `googleSheets`  \n**Description:** This node extracts data from the response body of a previous request and automatically inserts it into a specified Google Sheet. It allows for seamless data entry into your spreadsheet, making it ideal for logging, tracking, or storing information from API responses.\n\n**Key Features:**\n- Maps response body fields to sheet columns.\n- Supports multiple rows of data insertion.\n- Easily configurable with Google Sheets API credentials.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0c156367-aa5f-47ef-a9ba-e6e71bbea69e",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        120,
        -160
      ],
      "parameters": {
        "width": 400,
        "height": 520,
        "content": "### 7. \ud83d\udcca **Google Sheets - Insert 'Not Found' Record**\n**Type:** `googleSheets`  \n**Description:** This node inserts a record with the status \"Not Found\" into a Google Sheet when no relevant data is found in the response body. Ideal for logging missing data, tracking errors, or maintaining a record of failed API requests.\n\n**Key Features:**\n- Automatically inserts \"Not Found\" when data is missing or unavailable.\n- Customizable to log specific fields or add default messages.\n- Can be used to maintain error tracking or data gaps in a structured sheet."
      },
      "typeVersion": 1
    },
    {
      "id": "063d511c-30c5-4d1c-92f9-6455c4af7d73",
      "name": "Competitor Analysis Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -900,
        20
      ],
      "parameters": {
        "url": "https://competitor-analysis2.p.rapidapi.com/competitor.php",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "website",
              "value": "={{ $json.website }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-rapidapi-host",
              "value": "competitor-analysis2.p.rapidapi.com"
            },
            {
              "name": "x-rapidapi-key",
              "value": "your key"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4fccf5f4-5d91-4fb2-bd96-7f4ed5657c61",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2640,
        -420
      ],
      "parameters": {
        "width": 900,
        "height": 660,
        "content": "# Automated SEO Competitor Analysis and Google Sheets Logging\n\nThis n8n workflow automates competitor analysis by capturing website domains from user form submissions and sending them to a competitor analysis API via RapidAPI. It efficiently handles API responses, checking for valid data before appending detailed competitor information to a Google Sheet.\n\nIn case of missing or empty data, the workflow logs a \"Not data found\" entry to maintain consistent records. A built-in wait node controls the workflow pace, ensuring API rate limits are respected.\n\n**Key Features:**\n\n- User-friendly form input for website domains.\n- API integration for fetching competitor, organic page, and keyword data.\n- Conditional logic to verify response completeness.\n- Google Sheets integration for data storage and tracking.\n- Automated fallback logging for missing data.\n- Workflow pacing using wait/delay nodes.\n\n**Use Cases:**\n\n- SEO professionals seeking automated competitor insights.\n- Marketing teams needing consistent competitor data logs.\n- Agencies managing multiple domains for organic search analysis.\n\n---\n\n*Ensure to configure your RapidAPI key and Google Sheets credentials before running this workflow.*\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Global Storage": {
      "main": [
        [
          {
            "node": "Competitor Analysis Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Global Storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Competitor Analysis Request": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}