{
  "id": "Q0fs6FhvxUSO5kL4",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Google Search Console and Analytics Analysis with AI Optimizations",
  "tags": [],
  "nodes": [
    {
      "id": "4a4b478e-b5f8-4ddc-a6cc-48f1274cb5d6",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -300,
        -300
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "b52900dd-a2bd-42bb-8e1d-ce3cff259ec7",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        40,
        580
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "1ebe691b-6b76-4956-b181-c2be251d48be",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        480
      ],
      "parameters": {
        "width": 1620,
        "height": 640,
        "content": "## Get Google Data and Push It Through AI"
      },
      "typeVersion": 1
    },
    {
      "id": "7194a576-50ab-4df0-b6db-d6a74bcbb927",
      "name": "Enforce Order - Positions Last",
      "type": "n8n-nodes-base.merge",
      "position": [
        280,
        260
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition"
      },
      "typeVersion": 3
    },
    {
      "id": "be892b2b-6141-415c-a503-d4f7d467cc6a",
      "name": "Remove Duplicates",
      "type": "n8n-nodes-base.removeDuplicates",
      "position": [
        940,
        -60
      ],
      "parameters": {
        "compare": "selectedFields",
        "options": {},
        "fieldsToCompare": "loc"
      },
      "typeVersion": 2
    },
    {
      "id": "ebb767ad-a8db-449a-8d52-56731248e9e5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -140
      ],
      "parameters": {
        "width": 880,
        "height": 320,
        "content": "## Get All Pages From Sitemap"
      },
      "typeVersion": 1
    },
    {
      "id": "d421db5a-c224-44ef-a471-d64ca8ddaa69",
      "name": "Get sitemap XML",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        280,
        -60
      ],
      "parameters": {
        "url": "={{ $('Globals - CHANGE ME!').item.json.sitemap_url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "6bf0e08e-1cfa-4484-b953-cd215447d053",
      "name": "Convert to JSON",
      "type": "n8n-nodes-base.xml",
      "position": [
        500,
        -60
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "b5ab24fc-8c0f-4158-9452-35fc682246ff",
      "name": "Split Out to Table",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        720,
        -60
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "urlset.url"
      },
      "typeVersion": 1
    },
    {
      "id": "81c644b2-1de8-4f51-be73-ac2246fb3c5f",
      "name": "Limit for Testing Purposes",
      "type": "n8n-nodes-base.limit",
      "position": [
        1400,
        -60
      ],
      "parameters": {
        "maxItems": 5
      },
      "typeVersion": 1
    },
    {
      "id": "77c271b5-99b9-4adf-8b7f-7dc0846325bd",
      "name": "Wait to Comply with API Limits",
      "type": "n8n-nodes-base.wait",
      "position": [
        900,
        500
      ],
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "00b83323-17ef-44a1-82b1-eb867e532556",
      "name": "Globals - CHANGE ME!",
      "type": "n8n-nodes-base.set",
      "position": [
        40,
        -60
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "be81885f-3f27-4edd-985d-8dd98908a197",
              "name": "sitemap_url",
              "type": "string",
              "value": "https://sailingbyte.com/sitemap.xml"
            },
            {
              "id": "c1f4c9ba-9222-4757-a89e-0d67af1d3944",
              "name": "search_console_selector",
              "type": "string",
              "value": "sc-domain:example.com"
            },
            {
              "id": "9c57f9cc-1e94-4174-b622-7533c7776bee",
              "name": "analysis_start_date",
              "type": "string",
              "value": "={{ $now.minus(30,'days').format('yyyy-MM-dd') }}"
            },
            {
              "id": "51dd8171-2300-4574-9c71-56793127bf4a",
              "name": "analysis_end_date",
              "type": "string",
              "value": "={{ $now.format('yyyy-MM-dd') }}"
            },
            {
              "id": "5e09cf25-80d9-44fe-9cf3-e2517bcfc6e6",
              "name": "analytics_selector_id",
              "type": "number",
              "value": 0
            },
            {
              "id": "5befd844-afe6-44c9-8ecd-c2741d838b19",
              "name": "report_receiver",
              "type": "string",
              "value": "user@example.com"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cde1f4e7-f45d-4c64-906e-3b191550fc9a",
      "name": "Get Page GSC Status",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        280,
        560
      ],
      "parameters": {
        "url": "https://searchconsole.googleapis.com/v1/urlInspection/index:inspect",
        "method": "POST",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "inspectionUrl",
              "value": "={{ $json.loc }}"
            },
            {
              "name": "siteUrl",
              "value": "={{ $('Globals - CHANGE ME!').first().json.search_console_selector }}"
            }
          ]
        },
        "nodeCredentialType": "googleOAuth2Api"
      },
      "credentials": {
        "googleOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "c4856013-3111-4c04-b4d2-f92ad8f1cd88",
      "name": "Get Page GSC Stats",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueRegularOutput",
      "position": [
        280,
        740
      ],
      "parameters": {
        "url": "=https://www.googleapis.com/webmasters/v3/sites/{{ $('Globals - CHANGE ME!').first().json.search_console_selector }}/searchAnalytics/query",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"startDate\": \"{{ $('Globals - CHANGE ME!').first().json.analysis_start_date }}\",\n  \"endDate\": \"{{ $('Globals - CHANGE ME!').first().json.analysis_end_date }}\",\n  \"type\": \"web\",\n  \"dimensionFilterGroups\": [\n    {\n      \"groupType\": \"AND\",\n      \"filters\": [\n        {\n          \"dimension\": \"page\",\n          \"operator\": \"contains\",\n          \"expression\": \"{{ $json.loc }}\"\n        }\n      ]\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleOAuth2Api"
      },
      "credentials": {
        "googleOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "retryOnFail": true,
      "typeVersion": 4.2,
      "waitBetweenTries": 5000
    },
    {
      "id": "b5e8f02d-320c-4fab-9e38-2a6dbb97e7b1",
      "name": "Merge Status and Stats",
      "type": "n8n-nodes-base.merge",
      "position": [
        540,
        680
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineByPosition",
        "numberInputs": 3
      },
      "typeVersion": 3.2
    },
    {
      "id": "c7ff4009-65be-4d4a-b3dd-f711e7cefebb",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        660,
        880
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "o4-mini",
          "cachedResultName": "o4-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "133cbc78-a835-4d6c-a366-187d3f2ca4b1",
      "name": "Get Google Analytics Data",
      "type": "n8n-nodes-base.googleAnalytics",
      "position": [
        280,
        920
      ],
      "parameters": {
        "endDate": "={{ $('Globals - CHANGE ME!').first().json.analysis_end_date }}",
        "dateRange": "custom",
        "returnAll": true,
        "startDate": "={{ $('Globals - CHANGE ME!').first().json.analysis_start_date }}",
        "metricsGA4": {
          "metricValues": [
            {},
            {
              "listName": "screenPageViews"
            },
            {
              "listName": "userEngagementDuration"
            }
          ]
        },
        "propertyId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Globals - CHANGE ME!').first().json.analytics_selector_id }}"
        },
        "dimensionsGA4": {
          "dimensionValues": [
            {
              "listName": "pageLocation"
            }
          ]
        },
        "additionalFields": {
          "dimensionFiltersUI": {
            "filterExpressions": {
              "expression": {
                "stringFilter": [
                  {
                    "value": "={{ $json.loc }}",
                    "listName": "pageLocation",
                    "caseSensitive": false
                  }
                ]
              }
            }
          }
        }
      },
      "credentials": {
        "googleAnalyticsOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2,
      "alwaysOutputData": true
    },
    {
      "id": "fc55254f-012b-4387-af4c-54211b386182",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        940,
        880
      ],
      "parameters": {
        "url": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('URL', ``, 'string') }}",
        "options": {},
        "toolDescription": "Make HTTP request to get page data so you can further analyze page for SEO optimizations"
      },
      "typeVersion": 4.2
    },
    {
      "id": "3658c627-a22b-4f4c-b2ee-33e9a361bb1e",
      "name": "Merge AI Output With AI Input",
      "type": "n8n-nodes-base.merge",
      "position": [
        1400,
        900
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "b92d08c4-13a3-4c92-b37f-da3a7a5ee7dc",
      "name": "Markdown to HTML",
      "type": "n8n-nodes-base.markdown",
      "position": [
        1120,
        900
      ],
      "parameters": {
        "mode": "markdownToHtml",
        "options": {},
        "markdown": "={{ $json.output }}",
        "destinationKey": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "a77ef66d-1313-43ee-b23f-c23a24529026",
      "name": "Keep Only Valuable Columns",
      "type": "n8n-nodes-base.set",
      "position": [
        500,
        260
      ],
      "parameters": {
        "options": {
          "dotNotation": false,
          "ignoreConversionErrors": true
        },
        "assignments": {
          "assignments": [
            {
              "id": "6a86e547-b789-4319-886f-b06120967d64",
              "name": "loc",
              "type": "string",
              "value": "={{ $json.loc }}"
            },
            {
              "id": "8ba00cd3-e45a-439f-b703-8a42dd0628fa",
              "name": "inspectionResult.indexStatusResult.coverageState",
              "type": "string",
              "value": "={{ $json.inspectionResult.indexStatusResult.coverageState }}"
            },
            {
              "id": "b83dc435-cbb1-4dc3-8c7e-3af41201dbfe",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fad58242-29c7-4c48-ae3f-667559cfd644",
      "name": "Change to HTML table for sending",
      "type": "n8n-nodes-base.html",
      "position": [
        720,
        260
      ],
      "parameters": {
        "options": {},
        "operation": "convertToHtmlTable"
      },
      "typeVersion": 1.2
    },
    {
      "id": "3d737f97-9d5c-4f0c-8a2a-cbe98e0879d2",
      "name": "Send Email with Full report",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        940,
        260
      ],
      "parameters": {
        "html": "=<h2>Analysis is complete</h2>\n{{ $json.table }}\n\n",
        "options": {},
        "subject": "Your Analysis Is Complete",
        "toEmail": "={{ $('Globals - CHANGE ME!').first().json['report_receiver'] }}",
        "fromEmail": "={{ $('Globals - CHANGE ME!').first().json['report_receiver'] }}"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "8888143f-73ed-4ac7-84ee-b5b4bcf64c6e",
      "name": "Sort For Testing Purposes",
      "type": "n8n-nodes-base.sort",
      "position": [
        1180,
        -60
      ],
      "parameters": {
        "type": "random"
      },
      "typeVersion": 1
    },
    {
      "id": "fd4431b6-8a0a-4a2b-a70b-17d3fc2f34b5",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1140,
        -140
      ],
      "parameters": {
        "color": 6,
        "width": 440,
        "height": 320,
        "content": "## Limit for Testing"
      },
      "typeVersion": 1
    },
    {
      "id": "b821114e-234c-4183-a957-d5048f366ecd",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -20,
        -140
      ],
      "parameters": {
        "color": 4,
        "height": 320,
        "content": "## Setup Me First"
      },
      "typeVersion": 1
    },
    {
      "id": "2e0a5df7-7dd1-4ca7-b9e7-763928b32913",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        200
      ],
      "parameters": {
        "color": 3,
        "width": 1340,
        "height": 260,
        "content": "## Get Email Report"
      },
      "typeVersion": 1
    },
    {
      "id": "a16024d1-28a1-4b73-85b7-fc15e9620184",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -140
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 320,
        "content": "- sitemap_url - self exlpainatory\n- search_console_selector - for example \"sc-domain:sailingbyte.com\" but can be URL aswell- depends on how did you set up your search console\n- analysis_start_date and analysis_end_date - date range for analytics, by default last 30 days\n- analytics_selector_id - ID of Google Analytics setup, it is a large integer, you can find it in analytics url preceeded with letter \"p\", ex (your number is where there are X's): https://analytics.google.com/analytics/web/#/pXXXXXXXXX/reports/intelligenthome\n- report_receiver - email which will receive report "
      },
      "typeVersion": 1
    },
    {
      "id": "cd5d0d57-f04a-4094-8f26-855dd1051589",
      "name": "SEO analyst",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        780,
        680
      ],
      "parameters": {
        "text": "=You are professional SEO analyst and improver. You will receive in input data from Google Analytics and Google Search Console. Delivered data will be for single page.\n\nBased on this data, your task is to propose improvements, that are very specific to this page, and which will impact this web page positively. \n\nGeneral Data Evaluation:\n- How to get more users on this specific page\n- How to engage users more on this specific page\n- Analyze page itself for improvements\n- Look for potential issues in Google Analytics and Google Search Console data\n- Look for potential issues on website itself\n\nTechnical Evaluation:\n- Critical Fixes \u2013 Issues requiring immediate attention and resolution.\n- High-Impact Solutions \u2013 Simple adjustments that deliver significant results.\n- Enhancement Possibilities \u2013 Initiatives demanding greater investment but providing valuable long-term gains.\n\nContent Evaluation:\n- Keyword Strategy Assessment \u2013 Determine core and supporting search terms, evaluate keyword concentration levels, and examine strategic keyword positioning throughout the content.\n- Content Quality Review \u2013 Analyze the material's comprehensiveness, precision, and alignment with intended audience needs and expectations.\n- Accessibility and Clarity Analysis \u2013 Measure content comprehension difficulty through established readability frameworks including Flesch-Kincaid educational level, Flesch Reading Ease score, and Gunning-Fog complexity index.\n\nYou can add other improvement ideas, but they must be very specific to given page, no generalizations.\n\nWebsite is: {{ $json.pageLocation }}\n\nGoogle Analytics data is:\n- total users: {{ $json.totalUsers ?? 0}}\n- screen page views: {{ $json.screenPageViews ?? 0 }}\n- user engagement duration: {{ $json.userEngagementDuration ?? 0 }}\n\nGoogle Search Console data is:\n{{ $json.rows[0].toJsonString() }}\n\nIndexing status is as follows:\n{{ $json.inspectionResult.toJsonString() }}",
        "options": {},
        "promptType": "define"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "settings": {
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "5",
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveDataSuccessExecution": "all"
  },
  "versionId": "dc23ed85-f60d-4a41-b7c1-19cd5ac272b4",
  "connections": {
    "SEO analyst": {
      "main": [
        [
          {
            "node": "Markdown to HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "ai_tool": [
        [
          {
            "node": "SEO analyst",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Convert to JSON": {
      "main": [
        [
          {
            "node": "Split Out to Table",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get sitemap XML": {
      "main": [
        [
          {
            "node": "Convert to JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Enforce Order - Positions Last",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Get Page GSC Status",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Page GSC Stats",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Google Analytics Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Markdown to HTML": {
      "main": [
        [
          {
            "node": "Merge AI Output With AI Input",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "SEO analyst",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Remove Duplicates": {
      "main": [
        [
          {
            "node": "Sort For Testing Purposes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Page GSC Stats": {
      "main": [
        [
          {
            "node": "Merge Status and Stats",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Split Out to Table": {
      "main": [
        [
          {
            "node": "Remove Duplicates",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Page GSC Status": {
      "main": [
        [
          {
            "node": "Merge Status and Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Globals - CHANGE ME!": {
      "main": [
        [
          {
            "node": "Get sitemap XML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Status and Stats": {
      "main": [
        [
          {
            "node": "SEO analyst",
            "type": "main",
            "index": 0
          },
          {
            "node": "Wait to Comply with API Limits",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Google Analytics Data": {
      "main": [
        [
          {
            "node": "Merge Status and Stats",
            "type": "main",
            "index": 2
          }
        ]
      ]
    },
    "Sort For Testing Purposes": {
      "main": [
        [
          {
            "node": "Limit for Testing Purposes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep Only Valuable Columns": {
      "main": [
        [
          {
            "node": "Change to HTML table for sending",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit for Testing Purposes": {
      "main": [
        [
          {
            "node": "Enforce Order - Positions Last",
            "type": "main",
            "index": 0
          },
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge AI Output With AI Input": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enforce Order - Positions Last": {
      "main": [
        [
          {
            "node": "Keep Only Valuable Columns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait to Comply with API Limits": {
      "main": [
        [
          {
            "node": "Merge AI Output With AI Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Change to HTML table for sending": {
      "main": [
        [
          {
            "node": "Send Email with Full report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Globals - CHANGE ME!",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}