Error in Google Analytics node

Hi

I want to pull number of daily users from google analytics for 4 of my views.

When I used the example and added the credentials, I saw an error next to View Id field.
Screenshot from 2021-09-11 00-29-48

My credential is correct. I was able to pull some data without error.

Also, I don’t understand how date range works:
If I press yesterday while creating the workflow then will it return data for yesterday every day?

Welcome to the community @Rohit_Das

When I used the example and added the credentials, I saw an error next to View Id field.

That is weird, just tested it and it loads all the views for me. You set the View ID manually using expressions.

If I press yesterday while creating the workflow then will it return data for yesterday every day?

Not sure if I understand this, can you please elaborate? It seems like you want to set the date dynamically depending on when the workflow is executed, for example, the date before the current execution date. You can do that with expressions and creating the date either with the Date & Time node or a Function node

1 Like

Thanks @RicardoE105 for the welcome.

I will try everything from the start today and keep this thread posted if the error continues. I feel the error is cached somehow. When I first added the credentials, I forgot to enable the analytics API. That time the error was reasonable. But then when I enabled the API, this error persisted.

:white_check_mark: Manually adding VIEW ID works.

Yes, you understand it and you have pointed me in the right direction :wink:

I find n8n node editor a little confusing. So I will create the workflow in https://www.integromat.com/ and try duplicating it here.

Weird, after you enable the API, it should populate the views in your account. I would try deleting the node and adding it again.

I find n8n node editor a little confusing

Check the example workflow below. Copy and paste that in a new workflow.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        -2210,
        100
      ]
    },
    {
      "parameters": {
        "value": "={{new Date()}}",
        "options": {}
      },
      "name": "Date & Time",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        -1930,
        100
      ],
      "notesInFlow": true,
      "notes": "Get now"
    },
    {
      "parameters": {
        "action": "calculate",
        "value": "={{$node[\"Date & Time\"].json[\"data\"]}}",
        "operation": "subtract",
        "duration": 1,
        "options": {}
      },
      "name": "Date & Time1",
      "type": "n8n-nodes-base.dateTime",
      "typeVersion": 1,
      "position": [
        -1720,
        100
      ],
      "notesInFlow": true,
      "notes": "Now minus 1 day"
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Date & Time",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Date & Time": {
      "main": [
        [
          {
            "node": "Date & Time1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like