{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "68474035-4770-48f9-b559-21c2a383776d",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        10240,
        3232
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "44699fa5-8134-47da-bf36-3ac013d67d95",
      "name": "Get row(s) in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        10464,
        3232
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=0",
          "cachedResultName": "INPUT_WEBSITES"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "710d381f-2b9d-4395-83f5-ab4ae1b6b824",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        10688,
        3232
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bf16c862-c1ef-4d9f-81e9-3749143bda7c",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.Status }}",
              "rightValue": "NEW"
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "a29b4fac-07eb-4294-8232-a6c6ffc09f1e",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        10912,
        3232
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "56d02d57-33ab-4848-9599-95b2dfabfb3c",
              "name": "your_site",
              "type": "string",
              "value": "={{ $json.Your_Website }}"
            },
            {
              "id": "16d1ff38-45ef-4056-aab7-7244d8e8b10e",
              "name": "competitor_site",
              "type": "string",
              "value": "={{ $json.Competitor_Website }}"
            },
            {
              "id": "16a913eb-8894-41ed-a1f4-46ec467a24cf",
              "name": "row_number",
              "type": "number",
              "value": "={{ $json.row_number }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "be5308ec-af61-4bcf-96dd-87f79b807387",
      "name": "HTML (for My website)",
      "type": "n8n-nodes-base.html",
      "position": [
        11360,
        2960
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "title"
            },
            {
              "key": "meta_description",
              "attribute": "content",
              "cssSelector": "meta[name=\"description\"]",
              "returnValue": "attribute"
            },
            {
              "key": "h1",
              "cssSelector": "h1"
            },
            {
              "key": "h2",
              "cssSelector": "h2",
              "returnArray": true
            },
            {
              "key": "content",
              "cssSelector": "p",
              "returnArray": true
            },
            {
              "key": "internal_links",
              "attribute": "href",
              "cssSelector": "a[href^=\"/\"]",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "external_links",
              "attribute": "href",
              "cssSelector": "a[href^=\"http\"]",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "image",
              "attribute": "src",
              "cssSelector": "img",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "all_links",
              "attribute": "href",
              "cssSelector": "a",
              "returnArray": true,
              "returnValue": "attribute"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "daeb3c9a-2a39-4a1e-a53e-ab893f54f71a",
      "name": "All Links (My Website)",
      "type": "n8n-nodes-base.code",
      "position": [
        11584,
        3088
      ],
      "parameters": {
        "jsCode": "const baseUrl = $('Edit Fields').first().json.your_site.replace(/\\/$/, '');\nconst links = $json.all_links || [];\n\nconst importantKeywords = [\n  \"about\",\n  \"service\",\n  \"solution\",\n  \"product\",\n  \"blog\",\n  \"case\",\n  \"portfolio\",\n  \"contact\",\n  \"career\"\n];\n\nconst pages = [];\n\nfor (let link of links) {\n\n  if (!link) continue;\n\n  let fullUrl = \"\";\n\n  // convert relative links to full URL\n  if (link.startsWith(\"/\")) {\n    fullUrl = baseUrl + link;\n  } \n  else if (link.startsWith(baseUrl)) {\n    fullUrl = link;\n  }\n\n  if (!fullUrl) continue;\n\n  // remove anchors and query params\n  fullUrl = fullUrl.split(\"#\")[0].split(\"?\")[0];\n\n  // check if link contains important keywords\n  const lowerUrl = fullUrl.toLowerCase();\n\n  const isImportant = importantKeywords.some(keyword =>\n    lowerUrl.includes(keyword)\n  );\n\n  if (isImportant) {\n    pages.push(fullUrl);\n  }\n}\n\n// always include homepage\npages.unshift(baseUrl);\n\n// remove duplicates\nconst uniquePages = [...new Set(pages)];\n\nreturn uniquePages.map(url => {\n  return {\n    json: {\n      page_url: url\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "ab4f1cfb-0516-48f6-a5f7-5b8605c0b8e5",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        12704,
        3088
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "ae03a1fc-7981-428d-bdc0-c24eb823b9e1",
      "name": "HTTP Request2",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        12928,
        3056
      ],
      "parameters": {
        "url": "={{ $('Get Rows from All links').item.json.Page_URL }}",
        "options": {
          "response": {
            "response": {}
          }
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "34c8b57b-140e-4d63-9854-f0479a064ddd",
      "name": "My Website HTTP",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        11136,
        2960
      ],
      "parameters": {
        "url": "={{ $json.your_site }}",
        "options": {
          "response": {
            "response": {}
          }
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "507ff63c-2184-49e5-afb3-e84e7c7da4fe",
      "name": "HTTP (for Competitor)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        11360,
        3472
      ],
      "parameters": {
        "url": "={{ $('Edit Fields').item.json.competitor_site }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          }
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "c4617b95-ccad-4458-a672-d54276d8416a",
      "name": "HTML (for Competitor Website)",
      "type": "n8n-nodes-base.html",
      "position": [
        11584,
        3472
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "title"
            },
            {
              "key": "meta_description",
              "attribute": "content",
              "cssSelector": "meta[name=\"description\"]",
              "returnValue": "attribute"
            },
            {
              "key": "h1",
              "cssSelector": "h1"
            },
            {
              "key": "h2",
              "cssSelector": "h2",
              "returnArray": true
            },
            {
              "key": "content",
              "cssSelector": "p",
              "returnArray": true
            },
            {
              "key": "internal_links",
              "attribute": "href",
              "cssSelector": "a[href^=\"/\"]",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "external_links",
              "attribute": "href",
              "cssSelector": "a[href^=\"http\"]",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "image",
              "attribute": "src",
              "cssSelector": "img",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "all_links",
              "attribute": "href",
              "cssSelector": "a",
              "returnArray": true,
              "returnValue": "attribute"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7ee6b3ea-9f4a-46a5-b1bc-ad875a71dedb",
      "name": "Competitor Data",
      "type": "n8n-nodes-base.code",
      "position": [
        11808,
        3376
      ],
      "parameters": {
        "jsCode": "const item = $json;\n\n// paragraphs\nlet paragraphs = item.content || [];\nlet wordCount = 0;\n\nif (Array.isArray(paragraphs)) {\n  wordCount = paragraphs.join(\" \").split(/\\s+/).length;\n}\n\n// H2 cleanup\nlet h2 = [];\nif (Array.isArray(item.h2)) {\n  h2 = [...new Set(item.h2.map(h => h.trim()))];\n}\n\n// counts\nconst internalLinks = item.internal_links ? item.internal_links.length : 0;\nconst externalLinks = item.external_links ? item.external_links.length : 0;\nconst images = item.images ? item.images.length : 0;\n\nreturn [{\n  json: {\n    Website:$('Edit Fields').first().json.competitor_site ,\n    Page_URL:$('Edit Fields').first().json.competitor_site ,\n    Page_Title: item.title || \"\",\n    Meta_Description: item.meta_description || \"\",\n    H1: item.h1 || \"\",\n    H2: h2.join(\", \"),\n    Word_Count: wordCount,\n    Internal_Links: internalLinks,\n    External_Links: externalLinks,\n    Images: images,\n    Collected_Date: new Date().toISOString().split('T')[0]\n  }\n}];\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "6bb565e7-edfd-4c61-ba58-cf043a4b0d35",
      "name": "Append in Competitor Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        12032,
        3376
      ],
      "parameters": {
        "columns": {
          "value": {
            "H1": "={{ $json.H1 }}",
            "H2": "={{ $json.H2 }}",
            "ID": "={{ $('Get row(s) in sheet').item.json.ID }}",
            "Images": "={{ $json.Images }}",
            "Page_URL": "={{ $json.Page_URL }}",
            "Page_Title": "={{ $json.Page_Title }}",
            "Word_Count": "={{ $json.Word_Count }}",
            "Collected_Date": "={{ $json.Collected_Date }}",
            "External_Links": "={{ $json.External_Links }}",
            "Internal_Links": "={{ $json.Internal_Links }}",
            "Meta_Description": "={{ $json.Meta_Description }}",
            "Competitor_Website": "={{ $json.Website }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Competitor_Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Competitor_Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Meta_Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Meta_Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H1",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H2",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Word_Count",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Word_Count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Internal_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Internal_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "External_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "External_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Images",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Images",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Collected_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Collected_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 178777114,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=178777114",
          "cachedResultName": "COMPETITOR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "1c11904f-f422-4717-9094-a9e52d25e7f6",
      "name": "My Website Data",
      "type": "n8n-nodes-base.code",
      "position": [
        11584,
        2896
      ],
      "parameters": {
        "jsCode": "const item = $json;\n\n// paragraphs\nlet paragraphs = item.content || [];\nlet wordCount = 0;\n\nif (Array.isArray(paragraphs)) {\n  wordCount = paragraphs.join(\" \").split(/\\s+/).length;\n}\n\n// H2 cleanup\nlet h2 = [];\nif (Array.isArray(item.h2)) {\n  h2 = [...new Set(item.h2.map(h => h.trim()))];\n}\n\n// counts\nconst internalLinks = item.internal_links ? item.internal_links.length : 0;\nconst externalLinks = item.external_links ? item.external_links.length : 0;\nconst images = item.images ? item.images.length : 0;\n\nreturn [{\n  json: {\n    Website: $('Edit Fields').first().json.your_site,\n    Page_URL: $('Edit Fields').first().json.your_site,\n    Page_Title: item.title || \"\",\n    Meta_Description: item.meta_description || \"\",\n    H1: item.h1 || \"\",\n    H2: h2.join(\", \"),\n    Word_Count: wordCount,\n    Internal_Links: internalLinks,\n    External_Links: externalLinks,\n    Images: images,\n    Collected_Date: new Date().toISOString().split('T')[0]\n  }\n}];\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "3e25eabc-9fc7-4f48-9aa9-76c7f8dee8ae",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        12928,
        2864
      ],
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "80ee0e17-4219-4a9c-8c41-845fd8ec4b01",
      "name": "Append First Row of My website",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        11808,
        2896
      ],
      "parameters": {
        "columns": {
          "value": {
            "H1": "={{ $json.H1 }}",
            "H2": "={{ $json.H2 }}",
            "ID": "={{ $('Get row(s) in sheet').item.json.ID }}",
            "Images": "={{ $json.Images }}",
            "Website": "={{ $json.Website }}",
            "Page_URL": "={{ $json.Page_URL }}",
            "Page_Title": "={{ $json.Page_Title }}",
            "Word_Count": "={{ $json.Word_Count }}",
            "Collected_Date": "={{ $json.Collected_Date }}",
            "External_Links": "={{ $json.External_Links }}",
            "Internal_Links": "={{ $json.Internal_Links }}",
            "Meta_Description": "={{ $json.Meta_Description }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Meta_Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Meta_Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H1",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H2",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Word_Count",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Word_Count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Internal_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Internal_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "External_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "External_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Images",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Images",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Collected_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Collected_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 105835273,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=105835273",
          "cachedResultName": "YOUR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "ff2d2f31-cdd3-474c-9253-0c24fcc1b90f",
      "name": "All Links (Competitor Website)",
      "type": "n8n-nodes-base.code",
      "position": [
        11808,
        3568
      ],
      "parameters": {
        "jsCode": "const baseUrl = $('Edit Fields').first().json.competitor_site.replace(/\\/$/, '');\nconst links = $json.all_links || [];\n\nconst importantKeywords = [\n  \"about\",\n  \"service\",\n  \"solution\",\n  \"product\",\n  \"blog\",\n  \"case\",\n  \"portfolio\",\n  \"contact\",\n  \"career\"\n];\n\nconst pages = [];\n\nfor (let link of links) {\n\n  if (!link) continue;\n\n  let fullUrl = \"\";\n\n  // convert relative links to full URL\n  if (link.startsWith(\"/\")) {\n    fullUrl = baseUrl + link;\n  } \n  else if (link.startsWith(baseUrl)) {\n    fullUrl = link;\n  }\n\n  if (!fullUrl) continue;\n\n  // remove anchors and query params\n  fullUrl = fullUrl.split(\"#\")[0].split(\"?\")[0];\n\n  // check if link contains important keywords\n  const lowerUrl = fullUrl.toLowerCase();\n\n  const isImportant = importantKeywords.some(keyword =>\n    lowerUrl.includes(keyword)\n  );\n\n  if (isImportant) {\n    pages.push(fullUrl);\n  }\n}\n\n// always include homepage\npages.unshift(baseUrl);\n\n// remove duplicates\nconst uniquePages = [...new Set(pages)];\n\nreturn uniquePages.map(url => {\n  return {\n    json: {\n      page_url: url\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "e53b714c-847d-4cd2-aeae-d7c4b839a11e",
      "name": "HTML (All Links My Web)",
      "type": "n8n-nodes-base.html",
      "onError": "continueRegularOutput",
      "position": [
        13152,
        3056
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "title"
            },
            {
              "key": "meta_description",
              "attribute": "content",
              "cssSelector": "meta[name=\"description\"]",
              "returnValue": "attribute"
            },
            {
              "key": "h1",
              "cssSelector": "h1"
            },
            {
              "key": "h2",
              "cssSelector": "h2",
              "returnArray": true
            },
            {
              "key": "content",
              "cssSelector": "p",
              "returnArray": true
            },
            {
              "key": "internal_links",
              "attribute": "href",
              "cssSelector": "a[href^=\"/\"]",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "external_links",
              "attribute": "href",
              "cssSelector": "a[href^=\"http\"]",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "image",
              "attribute": "src",
              "cssSelector": "img",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "all_links",
              "attribute": "href",
              "cssSelector": "a",
              "returnArray": true,
              "returnValue": "attribute"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e43db405-354d-42f5-84ee-cc5692bb2ddc",
      "name": "All Links Data (My Website)",
      "type": "n8n-nodes-base.code",
      "position": [
        13376,
        3184
      ],
      "parameters": {
        "jsCode": "const item = $json;\n\nlet paragraphs = item.content || [];\nlet wordCount = 0;\n\nif (Array.isArray(paragraphs)) {\n  wordCount = paragraphs.join(\" \").split(/\\s+/).length;\n}\n\nlet h2 = [];\nif (Array.isArray(item.h2)) {\n  h2 = [...new Set(item.h2.map(h => h.trim()))];\n}\n\nconst internalLinks = item.internal_links ? item.internal_links.length : 0;\nconst externalLinks = item.external_links ? item.external_links.length : 0;\nconst images = item.images ? item.images.length : 0;\n\nreturn [{\n  json: {\n    Website:$('Edit Fields').first().json.your_site ,\n    Page_URL: $input.first().json.page_url,\n    Page_Title: item.title || \"\",\n    Meta_Description: item.meta_description || \"\",\n    H1: item.h1 || \"\",\n    H2: h2.join(\", \"),\n    Word_Count: wordCount,\n    Internal_Links: internalLinks,\n    External_Links: externalLinks,\n    Images: images,\n    Collected_Date: new Date().toISOString().split('T')[0]\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "43a8335e-0d79-486a-9863-04223b62d516",
      "name": "Inserted All Links in sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        12032,
        3088
      ],
      "parameters": {
        "columns": {
          "value": {
            "Page_URL": "={{ $json.page_url }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Meta_Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Meta_Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H1",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H2",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Word_Count",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Word_Count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Internal_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Internal_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "External_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "External_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Images",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Images",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Collected_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Collected_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "All Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "All Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 105835273,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=105835273",
          "cachedResultName": "YOUR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "bc127416-3d57-45db-ade3-28dcd66466d6",
      "name": "Inserted all Links (Competitor Website)",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        12032,
        3568
      ],
      "parameters": {
        "columns": {
          "value": {
            "Page_URL": "={{ $json.page_url }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Competitor_Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Competitor_Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Meta_Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Meta_Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H1",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H2",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Word_Count",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Word_Count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Internal_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Internal_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "External_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "External_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Images",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Images",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Collected_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Collected_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 178777114,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=178777114",
          "cachedResultName": "COMPETITOR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "529eed28-d597-4f46-8e0b-38b3d97b5432",
      "name": "Get row(s) in sheet2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        12480,
        3568
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.Page_URL }}",
              "lookupColumn": "Page_URL"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 178777114,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=178777114",
          "cachedResultName": "COMPETITOR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "6df6de0a-49fe-40e3-a47d-23b4431ce135",
      "name": "Get Rows from All links",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        12480,
        3088
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.Page_URL }}",
              "lookupColumn": "Page_URL"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 105835273,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=105835273",
          "cachedResultName": "YOUR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "565fbeef-3734-4b64-b515-f96c98faa22c",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        12704,
        3568
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "0bfb6ed4-4479-49e0-bf7a-e29e3e387d15",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        12928,
        3568
      ],
      "parameters": {
        "url": "={{ $('Get row(s) in sheet2').item.json.Page_URL }}",
        "options": {
          "response": {
            "response": {}
          }
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "926fbdee-7069-41d7-92d3-c1d95cd8948e",
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "position": [
        12928,
        3376
      ],
      "parameters": {
        "amount": 2
      },
      "typeVersion": 1.1
    },
    {
      "id": "e9cba612-b849-4fbb-86f2-92f2ba2ecc85",
      "name": "Update row in Competitor Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        13152,
        3376
      ],
      "parameters": {
        "columns": {
          "value": {
            "H1": "={{ $json.H1 }}",
            "H2": "={{ $json.H2 }}",
            "Images": "={{ $json.Images }}",
            "Page_URL": "={{ $('Get row(s) in sheet2').item.json.Page_URL }}",
            "Page_Title": "={{ $json.Page_Title }}",
            "Word_Count": "={{ $json.Word_Count }}",
            "Collected_Date": "={{ $json.Collected_Date }}",
            "External_Links": "={{ $json.External_Links }}",
            "Internal_Links": "={{ $json.Internal_Links }}",
            "Meta_Description": "={{ $json.Meta_Description }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Page_URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Meta_Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Meta_Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H1",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H2",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Word_Count",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Word_Count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Internal_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Internal_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "External_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "External_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Images",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Images",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Collected_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Collected_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "All Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "All Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Page_URL"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 178777114,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=178777114",
          "cachedResultName": "COMPETITOR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "32f35dba-cdfd-4607-a3c6-6f053cbda20a",
      "name": "Update row in My Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        13152,
        2864
      ],
      "parameters": {
        "columns": {
          "value": {
            "H1": "={{ $json.H1 }}",
            "H2": "={{ $json.H2 }}",
            "Images": "={{ $json.Images }}",
            "Page_URL": "={{ $('Get Rows from All links').item.json.Page_URL }}",
            "Page_Title": "={{ $json.Page_Title }}",
            "Word_Count": "={{ $json.Word_Count }}",
            "Collected_Date": "={{ $json.Collected_Date }}",
            "External_Links": "={{ $json.External_Links }}",
            "Internal_Links": "={{ $json.Internal_Links }}",
            "Meta_Description": "={{ $json.Meta_Description }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_URL",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Page_URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Page_Title",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Page_Title",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Meta_Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Meta_Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H1",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H1",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "H2",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "H2",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Word_Count",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Word_Count",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Internal_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Internal_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "External_Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "External_Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Images",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Images",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Collected_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Collected_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "All Links",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "All Links",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Page_URL"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 105835273,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=105835273",
          "cachedResultName": "YOUR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "cf187f2f-73ba-465b-8f02-868867b5108e",
      "name": "Get All data from Competitor Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        13600,
        3376
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.Page_URL }}",
              "lookupColumn": "Page_URL"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 178777114,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=178777114",
          "cachedResultName": "COMPETITOR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "333d1db3-9d3e-4544-82ee-d21d69d30a3a",
      "name": "Get All data from My Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        13600,
        2864
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "={{ $json.Page_URL }}",
              "lookupColumn": "Page_URL"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 105835273,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=105835273",
          "cachedResultName": "YOUR_SEO_DATA"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "823137e2-be7d-4e1f-a915-0e8c20e11a42",
      "name": "Wait2",
      "type": "n8n-nodes-base.wait",
      "position": [
        12256,
        3568
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "7cbd00ea-a22c-4e91-8d10-0032b4aa7b45",
      "name": "Wait3",
      "type": "n8n-nodes-base.wait",
      "position": [
        11808,
        3088
      ],
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "3ccad78e-7925-4e16-89a2-fac8bf2685c8",
      "name": "Wait4",
      "type": "n8n-nodes-base.wait",
      "position": [
        12256,
        3088
      ],
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "1f7979ac-e3ca-44fd-b242-cc5de34de3ce",
      "name": "Wait5",
      "type": "n8n-nodes-base.wait",
      "position": [
        13376,
        2864
      ],
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "fed93104-844e-4b69-9fc9-b0f9ae9bcb66",
      "name": "Wait6",
      "type": "n8n-nodes-base.wait",
      "position": [
        13376,
        3376
      ],
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "ff368ee4-1f22-43be-a0f0-b50c35344c15",
      "name": "HTML (All Links Competitor Website)",
      "type": "n8n-nodes-base.html",
      "onError": "continueRegularOutput",
      "position": [
        13152,
        3568
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "title",
              "cssSelector": "title"
            },
            {
              "key": "meta_description",
              "attribute": "content",
              "cssSelector": "meta[name=\"description\"]",
              "returnValue": "attribute"
            },
            {
              "key": "h1",
              "cssSelector": "h1"
            },
            {
              "key": "h2",
              "cssSelector": "h2",
              "returnArray": true
            },
            {
              "key": "content",
              "cssSelector": "p",
              "returnArray": true
            },
            {
              "key": "internal_links",
              "attribute": "href",
              "cssSelector": "a[href^=\"/\"]",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "external_links",
              "attribute": "href",
              "cssSelector": "a[href^=\"http\"]",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "image",
              "attribute": "src",
              "cssSelector": "img",
              "returnArray": true,
              "returnValue": "attribute"
            },
            {
              "key": "all_links",
              "attribute": "href",
              "cssSelector": "a",
              "returnArray": true,
              "returnValue": "attribute"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5d64f117-269e-4b54-8c32-f0c697a7c05d",
      "name": "All Links Data (Competitor Website)",
      "type": "n8n-nodes-base.code",
      "position": [
        13376,
        3712
      ],
      "parameters": {
        "jsCode": "const item = $json;\n\nlet paragraphs = item.content || [];\nlet wordCount = 0;\n\nif (Array.isArray(paragraphs)) {\n  wordCount = paragraphs.join(\" \").split(/\\s+/).length;\n}\n\nlet h2 = [];\nif (Array.isArray(item.h2)) {\n  h2 = [...new Set(item.h2.map(h => h.trim()))];\n}\n\nconst internalLinks = item.internal_links ? item.internal_links.length : 0;\nconst externalLinks = item.external_links ? item.external_links.length : 0;\nconst images = item.images ? item.images.length : 0;\n\nreturn [{\n  json: {\n    Website:$('Edit Fields').first().json.your_site ,\n    Page_URL: $input.first().json.page_url,\n    Page_Title: item.title || \"\",\n    Meta_Description: item.meta_description || \"\",\n    H1: item.h1 || \"\",\n    H2: h2.join(\", \"),\n    Word_Count: wordCount,\n    Internal_Links: internalLinks,\n    External_Links: externalLinks,\n    Images: images,\n    Collected_Date: new Date().toISOString().split('T')[0]\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "0bffd008-4a60-4fce-bec2-1ea3e9f95ed3",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        13824,
        3232
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "ef02f8c5-1801-45b3-8b21-e99d5b8676cc",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        14048,
        3232
      ],
      "parameters": {
        "jsCode": "const yourData = [];\nconst competitorData = [];\n\nfor (const item of $input.all()) {\n\n  if (item.json.Website !== undefined) {\n    yourData.push(item.json);\n  }\n\n  if (item.json.Competitor_Website !== undefined) {\n    competitorData.push(item.json);\n  }\n\n}\n\nconst mergedData = {\n  your_website_data: yourData,\n  competitor_website_data: competitorData\n};\n\nreturn [\n  {\n    json: mergedData,\n    pairedItem: { item: 0 }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "54789e22-ace7-4981-b6fb-d6da04fd38a2",
      "name": "Code in JavaScript1",
      "type": "n8n-nodes-base.code",
      "position": [
        14624,
        3232
      ],
      "parameters": {
        "jsCode": "// Get Gemini response text\nlet rawText = $json.content.parts[0].text;\n\n// Remove markdown code blocks\nrawText = rawText.replace(/```json/g, '')\n                 .replace(/```/g, '')\n                 .trim();\n\n// Remove markdown bold (**text**)\nrawText = rawText.replace(/\\*\\*/g, '');\n\n// Extract JSON object\nconst jsonMatch = rawText.match(/\\{[\\s\\S]*\\}/);\n\nif (!jsonMatch) {\n  throw new Error(\"No valid JSON found in AI output: \" + rawText);\n}\n\nlet parsed;\n\ntry {\n  parsed = JSON.parse(jsonMatch[0]);\n} catch (error) {\n  throw new Error(\"AI output is not valid JSON: \" + jsonMatch[0]);\n}\n\n// Return parsed JSON\nreturn [\n  {\n    json: parsed\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "c3bba3b3-369c-4aef-a70e-c17550b86da7",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        14848,
        3232
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $json.ID }}",
            "Content_Gap": "={{ $json.Content_Gap }}",
            "Keyword_Gap": "={{ $json.Keyword_Gap }}",
            "Your_Website": "={{ $json.Your_Website }}",
            "Analysis_Date": "={{ $now }}",
            "Technical_SEO_Gap": "={{ $json.Technical_SEO_Gap }}",
            "Competitor_Website": "={{ $json.Competitor_Website }}",
            "Suggested_Keywords": "={{ $json.Suggested_Keywords }}",
            "Missing_Blog_Topics": "={{ $json.Missing_Blog_Topics }}",
            "SEO_Improvement_Plan": "={{ $json.SEO_Improvement_Plan }}",
            "Suggested_Blog_Topics": "={{ $json.Suggested_Blog_Topics }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Your_Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Your_Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Competitor_Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Competitor_Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Keyword_Gap",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Keyword_Gap",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Content_Gap",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Content_Gap",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Technical_SEO_Gap",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Technical_SEO_Gap",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Missing_Blog_Topics",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Missing_Blog_Topics",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Suggested_Keywords",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Suggested_Keywords",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Suggested_Blog_Topics",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Suggested_Blog_Topics",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "SEO_Improvement_Plan",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "SEO_Improvement_Plan",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Analysis_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Analysis_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1641451707,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=1641451707",
          "cachedResultName": "SEO_GAP_REPORT"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "d214d40d-cc71-4f64-8155-bff956fd7b29",
      "name": "Update row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        15072,
        3232
      ],
      "parameters": {
        "columns": {
          "value": {
            "ID": "={{ $json.ID }}",
            "Status": "DONE",
            "Processed_Date": "={{ $now }}"
          },
          "schema": [
            {
              "id": "ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Your_Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Your_Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Competitor_Website",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Competitor_Website",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Created_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Processed_Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Processed_Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "ID"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit#gid=0",
          "cachedResultName": "INPUT_WEBSITES"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/10CR_uR1PWHhLhtw2T_BVWQ1mFjwSkslkewfd7Og1EPI/edit?usp=drivesdk",
          "cachedResultName": "SEO_Workflow"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "44eb3e31-0e82-4cc2-aeff-e0af17514885",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        9360,
        2752
      ],
      "parameters": {
        "width": 768,
        "height": 1200,
        "content": "# SEO Content Gap Analyzer\n\n### How it works\n\nThis workflow compares your website with competitor websites to identify SEO gaps. It starts by reading URLs from Google Sheets and filtering only new entries. It then scrapes key SEO elements such as titles, meta descriptions, headings, and page content from both sites. The workflow expands into important internal pages (like services, blogs, and contact pages) to ensure deeper analysis.\n\nAll collected data is structured and stored before being sent to Google Gemini AI. The AI analyzes differences between both websites to identify keyword gaps, missing content, technical SEO issues, and opportunities for improvement. Finally, it generates a structured SEO report including suggested keywords, blog topics, and an improvement plan, which is saved back into Google Sheets.\n\n### Setup steps\n\n1. Connect your Google Sheets account.\n2. Add your website and competitor URLs in the input sheet.\n3. Connect your Google Gemini API credentials.\n4. Ensure sheets for output data and reports are properly configured.\n\n### Customization tips\n\n- Add more competitors for broader analysis.\n- Adjust page filtering logic for deeper crawling.\n- Modify the AI prompt for different SEO outputs."
      },
      "typeVersion": 1
    },
    {
      "id": "53867f4a-7993-4694-b0fd-398ea978ae6e",
      "name": "Message a model",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        14272,
        3232
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=You are an SEO expert.\n\nCompare the SEO data of two websites.\n\nYour Website: {{ $('Edit Fields').item.json.your_site }}\nCompetitor Website: {{ $('Edit Fields').item.json.competitor_site }}\nAnalyze the following:\n\n1 Keyword Gap\n2 Content Gap\n3 Technical SEO Gap\n4 Missing Blog Topics\n5 Suggested Keywords\n6 Suggested Blog Topics\n7 SEO Improvement Plan\n\nReturn the result strictly in this JSON format:\n\n{\n\"ID\":\"\",\n\"Your_Website\":\"\",\n\"Competitor_Website\":\"\",\n\"Keyword_Gap\":\"\",\n\"Content_Gap\":\"\",\n\"Technical_SEO_Gap\":\"\",\n\"Missing_Blog_Topics\":\"\",\n\"Suggested_Keywords\":\"\",\n\"Suggested_Blog_Topics\":\"\",\n\"SEO_Improvement_Plan\":\"\",\n\"Analysis_Date\":\"{{ $now }}\"\n}\n\nHere is the data:\n\nMy Website Data:\n{{ $json.your_website_data }}\n\nCompetitor Website Data:\n{{ $json.competitor_website_data }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "17e9af60-d191-41ad-8393-53c436471d0d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        10144,
        2752
      ],
      "parameters": {
        "color": 7,
        "width": 928,
        "height": 1200,
        "content": "# **Input & Validation** #\n\nReads URLs from Google Sheets  \nFilters only NEW rows for processing"
      },
      "typeVersion": 1
    },
    {
      "id": "336653fb-4de3-42ca-b53a-e1cba26c51c6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        11088,
        2752
      ],
      "parameters": {
        "color": 7,
        "width": 2656,
        "height": 1200,
        "content": "# **Data Collection** #\n\nScrapes SE  O data from both websites  \nExtracts pages, content, and structure"
      },
      "typeVersion": 1
    },
    {
      "id": "0a1cf2d8-cac3-4a61-bc3d-056b155c0e69",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        13760,
        2752
      ],
      "parameters": {
        "color": 7,
        "width": 1568,
        "height": 1200,
        "content": "# **AI SEO Analysis** #\n\nCompares both datasets using Gemini  \nGenerates SEO gap report"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Update row in My Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Update row in Competitor Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait2": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait3": {
      "main": [
        [
          {
            "node": "Inserted All Links in sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait4": {
      "main": [
        [
          {
            "node": "Get Rows from All links",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait5": {
      "main": [
        [
          {
            "node": "Get All data from My Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait6": {
      "main": [
        [
          {
            "node": "Get All data from Competitor Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "My Website HTTP",
            "type": "main",
            "index": 0
          },
          {
            "node": "HTTP (for Competitor)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "HTML (All Links Competitor Website)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request2": {
      "main": [
        [
          {
            "node": "HTML (All Links My Web)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Competitor Data": {
      "main": [
        [
          {
            "node": "Append in Competitor Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Message a model": {
      "main": [
        [
          {
            "node": "Code in JavaScript1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "My Website Data": {
      "main": [
        [
          {
            "node": "Append First Row of My website",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "My Website HTTP": {
      "main": [
        [
          {
            "node": "HTML (for My website)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Message a model",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript1": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get row(s) in sheet2": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML (for My website)": {
      "main": [
        [
          {
            "node": "My Website Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "All Links (My Website)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP (for Competitor)": {
      "main": [
        [
          {
            "node": "HTML (for Competitor Website)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "All Links (My Website)": {
      "main": [
        [
          {
            "node": "Wait3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row in My Sheet": {
      "main": [
        [
          {
            "node": "Wait5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Rows from All links": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML (All Links My Web)": {
      "main": [
        [
          {
            "node": "All Links Data (My Website)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All data from My Sheet": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "All Links Data (My Website)": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inserted All Links in sheets": {
      "main": [
        [
          {
            "node": "Wait4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML (for Competitor Website)": {
      "main": [
        [
          {
            "node": "Competitor Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "All Links (Competitor Website)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "All Links (Competitor Website)": {
      "main": [
        [
          {
            "node": "Inserted all Links (Competitor Website)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update row in Competitor Sheet": {
      "main": [
        [
          {
            "node": "Wait6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All data from Competitor Sheet": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "All Links Data (Competitor Website)": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML (All Links Competitor Website)": {
      "main": [
        [
          {
            "node": "All Links Data (Competitor Website)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get row(s) in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inserted all Links (Competitor Website)": {
      "main": [
        [
          {
            "node": "Wait2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}