There was an error when connecting to Google Analytics

Hello everyone, I am a newbie who is new to N8N, when I was using my google analytics node, the credential verification was successfully connected, but after I entered my resource id and pressed test, he had the following problem, how can I solve it?

`{
  "errorMessage": "404 - \"<!DOCTYPE html>\\n<html lang=en>\\n  <meta charset=utf-8>\\n  <meta name=viewport content=\\\"initial-scale=1, minimum-scale=1, width=device-width\\\">\\n  <title>Error 404 (Not Found)!!1</title>\\n  <style>\\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\\n  </style>\\n  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\\n  <p><b>404.</b> <ins>That’s an error.</ins>\\n  <p>The requested URL <code>/v1beta/properties/:runReport</code> was not found on this server.  <ins>That’s all we know.</ins>\\n\"",
  "errorDescription": "<!DOCTYPE html>\n<html lang=en>\n  <meta charset=utf-8>\n  <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\n  <title>Error 404 (Not Found)!!1</title>\n  <style>\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\n  </style>\n  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\n  <p><b>404.</b> <ins>That’s an error.</ins>\n  <p>The requested URL <code>/v1beta/properties/:runReport</code> was not found on this server.  <ins>That’s all we know.</ins>\n",
  "errorDetails": {
    "rawErrorMessage": [
      "404 - \"<!DOCTYPE html>\\n<html lang=en>\\n  <meta charset=utf-8>\\n  <meta name=viewport content=\\\"initial-scale=1, minimum-scale=1, width=device-width\\\">\\n  <title>Error 404 (Not Found)!!1</title>\\n  <style>\\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\\n  </style>\\n  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\\n  <p><b>404.</b> <ins>That’s an error.</ins>\\n  <p>The requested URL <code>/v1beta/properties/:runReport</code> was not found on this server.  <ins>That’s all we know.</ins>\\n\""
    ],
    "httpCode": "404"
  },
  "n8nDetails": {
    "nodeName": "Google Analytics1",
    "nodeType": "n8n-nodes-base.googleAnalytics",
    "nodeVersion": 2,
    "resource": "report",
    "operation": "get",
    "time": "2024/9/4 下午12:35:14",
    "n8nVersion": "1.56.2 (Self Hosted)",
    "binaryDataMode": "default",
    "stackTrace": [
      "NodeApiError: 404 - \"<!DOCTYPE html>\\n<html lang=en>\\n  <meta charset=utf-8>\\n  <meta name=viewport content=\\\"initial-scale=1, minimum-scale=1, width=device-width\\\">\\n  <title>Error 404 (Not Found)!!1</title>\\n  <style>\\n    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}\\n  </style>\\n  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>\\n  <p><b>404.</b> <ins>That’s an error.</ins>\\n  <p>The requested URL <code>/v1beta/properties/:runReport</code> was not found on this server.  <ins>That’s all we know.</ins>\\n\"",
      "    at Object.googleApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Analytics/v2/transport/index.js:48:15)",
      "    at processTicksAndRejections (node:internal/process/task_queues:95:5)",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Analytics/v2/actions/report/get.ga4.operation.js:554:25)",
      "    at Object.router (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Analytics/v2/actions/router.js:46:36)",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Analytics/v2/GoogleAnalyticsV2.node.js:16:16)",
      "    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:728:19)",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:673:51",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1104:20"
    ]
  }
}`

! [截圖 2024-09-04 12.44.05|690x482] (upload://49wrwF1hjAOvcpKRWzvTCJtWx1v.jpeg)

Thank you for your support

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

I’m glad to hear from you, and I have the following information:

  • n8n version:
    1.56.2

  • Database (default: SQLite):
    I should have used the preset

  • n8n EXECUTIONS_PROCESS setting (default: own, main):
    I should have used the preset

  • Running n8n via (Docker, npm, n8n cloud, desktop app):
    I use Docker with 1panel

  • Operating system:
    Ubuntu 22.04 x64

Thanks again for your reply

Hello @acejou ,

Welcome to the n8n community. And thanks for sharing the issue you are facing.

I have checked your issue and yes it seems credentials are OK as you got error 404 back(it suggests credentials worked fine).

However HTTP 404 means that the url you tried to access on Google side(analytics) does not exist. It could be it is not correct. 404 Not Found - HTTP | MDN

Can you validate it outside n8n node?
Can you share your flow or snippet of it so we can check?

<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
    <p><b>404.</b> 
      <ins>That’s an error.</ins>\\n  
      <p>The requested URL
 <code>/v1beta/properties/:runReport</code> 
was not found on this server. 
 <ins>That’s all we know.</ins>\\n\"",
            
      "    at Object.googleApiRequest (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Analytics/v2/transport/index.js:48:15)",
      "    at processTicksAndRejections (node:internal/process/task_queues:95:5)",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Analytics/v2/actions/report/get.ga4.operation.js:554:25)",
      "    at Object.router (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Analytics/v2/actions/router.js:46:36)",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Google/Analytics/v2/GoogleAnalyticsV2.node.js:16:16)",
      "    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:728:19)",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:673:51",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1104:20"

Thank you
First of all, I’m a person with no coding experience
So you proposed to verify it outside of the n8n node I don’t know how

The following is my json, please refer to it, thank you

`{
  "name": "每月報表",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "months",
              "triggerAtDayOfMonth": 5
            }
          ]
        }
      },
      "id": "1048ed03-a041-42db-bc87-900b99675f47",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        600,
        320
      ]
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "19eIulAD1tyaXEBt8n4n3_zibwoGCQPGq0q84sT3ngsw",
          "mode": "list",
          "cachedResultName": "默默行銷月報表",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19eIulAD1tyaXEBt8n4n3_zibwoGCQPGq0q84sT3ngsw/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "網站資料",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/19eIulAD1tyaXEBt8n4n3_zibwoGCQPGq0q84sT3ngsw/edit#gid=0"
        },
        "options": {}
      },
      "id": "fab364b7-6faf-4397-98a3-cc1e111f8589",
      "name": "取用GA-ID",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        820,
        320
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "cLHImX1uAv6PK86b",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "propertyId": {
          "__rl": true,
          "value": "={{ $json['GA-ID'] }}",
          "mode": "id"
        },
        "metricsGA4": {
          "metricValues": [
            {}
          ]
        },
        "dimensionsGA4": {
          "dimensionValues": [
            {}
          ]
        },
        "additionalFields": {}
      },
      "id": "1c145d75-81c2-4fe4-a346-452cfa2ad9bb",
      "name": "Google Analytics",
      "type": "n8n-nodes-base.googleAnalytics",
      "typeVersion": 2,
      "position": [
        1680,
        80
      ],
      "credentials": {
        "googleAnalyticsOAuth2": {
          "id": "JTKC1EaWlPeLkpt1",
          "name": "Google Analytics account"
        }
      }
    },
    {
      "parameters": {
        "propertyId": {
          "__rl": true,
          "value": "={{ $json['GA-ID'] }}",
          "mode": "id"
        },
        "metricsGA4": {
          "metricValues": [
            {}
          ]
        },
        "dimensionsGA4": {
          "dimensionValues": [
            {}
          ]
        },
        "additionalFields": {}
      },
      "id": "d0a1d99c-ae40-4d6e-b376-66841e116bfb",
      "name": "Google Analytics1",
      "type": "n8n-nodes-base.googleAnalytics",
      "typeVersion": 2,
      "position": [
        1020,
        320
      ],
      "credentials": {
        "googleAnalyticsOAuth2": {
          "id": "JTKC1EaWlPeLkpt1",
          "name": "Google Analytics account"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "取用GA-ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "取用GA-ID": {
      "main": [
        [
          {
            "node": "Google Analytics1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "520c6ca1-6138-4a5e-a9ea-a974fccb5ee6",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "633a3d0fba1a7112c54c94e822a74e42668b515bf3665dd83b0257a2d9baaff1"
  },
  "id": "YBZXghNrckCudf4l",
  "tags": []
}`

Hello @acejou ,

Thank you for sharing the details of your workflow and highlight the no-code nature you come from.

By validating it externally, I was thinking about using a tool like postman to execute the call against Google Analytics to confirm it works. Or perhaps an easier way could be:

log into Google Analytics in your chorme browser for example and then copy and paste the URL https://analyticsdata.googleapis.com/v1beta/properties/{propertyId}:runReport

to the browser(NOTE that you need to replace the {propertyId} in the url above with the actual propertyID. Does it work???

Looking at your flow, my first suggestion would be to use only the Google Analytics and remove the Google sheet for the moment. Instead of using {{ $json[‘GA-ID’] }}", add the Property ID direcly in a hardcode way. Does it work?

I am thinking in certify if the data pulled from the Google Sheet is wrong or contains any issue.

Another point to check is about the permissions.Review the OAuth2 credentials or API key used in n8n to ensure they have the necessary scopes and permissions to access the Google Analytics data.

On a side question, are you testing from n8n Docker instance or from Cloud?

I am adding here for your reference the links about n8n credentials for Google and the official Google Analytics documentation: