I am trying to get data from my Google Analytics account(v4) through a nodeJs API.
This is my code
const getApGaData = async (propertyId = "259735053") => {
const analyticsDataClient = new BetaAnalyticsDataClient();
const response = await analyticsDataClient.runReport({
property: `properties/${propertyId}`,
dateRanges: [
{
startDate: "2021-02-20",
endDate: "today",
},
],
dimensions: [
{
name: "date",
},
],
metrics: [
{
name: "activeUsers",
},
],
});
console.log(response);
};
getApGaData()
This is my .env file
GOOGLE_APPLICATION_CREDENTIALS="./google-services.json"
The response I am getting is
[ [ { name: 'date' } ], null, null ]
I am unable to figure out the mistake I am making. I have created a GCP project, enable GA Data API, created service credentials, added the service email to my GA giving access.