2017-08-01 78 views
1

我有一个节点应用程序。在这里,我试图使用Google API从谷歌分析中获取推荐流。我已经提到了尺寸,指标和其他所需参数。这里是我的代码片段,如何使用谷歌分析API获取推荐流程?

// 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); 

}); 

这里它只返回与入口相关的数据。但我需要为每次推介访问获取流量。例如,如果用户从google进入主页并转到第2页,第3页并退出网站,那么我需要跟踪此流程。这如何使用谷歌分析API来完成?

回答