1
votes

I have a node application. Here I'm trying to fetch the referral flow from google analytics using Google API. I have mentioned the dimensions, metrics and other required parameters. Here is my code snippet,

// imported googleapis npm module
import google from "googleapis";
const analytics = google.analytics("v3");

// This is my payload to get the required analytics data
const analyticsData = {
  auth: oauth2Creds,
  accountId: "accountID",
  webPropertyId: "webPropertyID",
  profileId: "profileID",
  ids: "ga:id",
  "start-date": "90daysAgo",
  "end-date": "today",
  metrics: "ga:pageValue,ga:pageviews,ga:entranceRate,ga:exitRate",
  dimensions: "ga:fullReferrer",
  "start-index": "1"
};

// Function to get analytical data using the above payload
analytics.data.ga.get(analyticsData, (err, result) => {

  // I will get the results here
  console.log(result);

});

Here it returns only the data related to the entrance. But I need to get the flow for each referral visits. For ex, if a user enters into the home page from google and moves to page2, page3 and exits the website, then I need to track this flow. How can this be done using google analytics API?

1

1 Answers

0
votes

I might not be answering your question directly but I think the following documentation might assist you.

https://developers.google.com/analytics/devguides/reporting/mcf/v3/