insufficient Permissions error facing also not able to find out View ID

The error message “User does not have sufficient permissions for this profile” means that the service account you are using does not have the necessary permissions to access the Google Analytics data you are trying to fetch.

To fix this, you need to grant the service account the appropriate permissions. You can do this by following these steps:

  1. Go to the Google Cloud Platform Console: https://console.cloud.google.com/.
  2. Click the IAM & Admin tab.
  3. Click the Service accounts tab.
  4. Find the service account you are using and click the Edit button.
  5. In the Permissions section, add the Google Analytics Admin role.
  6. Click the Save button.

Once you have granted the service account the necessary permissions, you should be able to fetch the Google Analytics data without any errors.

If you are still having trouble, you can contact Google Cloud support for help.

As for the issue of not being able to find the View ID, you can use the following steps to find it:

  1. Go to the Google Analytics website: https://analytics.google.com/.
  2. Sign in to your account.
  3. Click the Admin tab.
  4. In the View section, find the View ID for the property you want to fetch data from.

The View ID is a 16-digit alphanumeric string that starts with “ga:”. You can use this View ID in your code to fetch data from the specified Google Analytics property.