
[英]Google Analytics Management Api Insert Goal: 403 Insufficient permission .net
[英]Analytics Scripts Insufficient Permission from Google Sheets
我正在嘗試編寫腳本以獲取Google Analytics(分析)數據並將其添加到Google表格中。
運行以下代碼時,在工作表上出現以下錯誤:
“用戶對此個人資料沒有足夠的權限。”
只需幾個快速復選框即可:是,我正在嘗試訪問的Analytics(分析)帳戶具有管理員權限,是,我正在創建腳本的Google表格具有管理權限,是的,我已經檢查了我當前的Google登錄名,以確保我使用的帳戶正確。
這是代碼:
function runDemo() {
try {
var results = getReportDataForProfile();
outputToSpreadsheet(results);
} catch(error) {
Browser.msgBox(error.message);
}
}
function getReportDataForProfile() {
var profileId = 'xxxxxxxx'; //firstProfile.getId();
var tableId = 'ga:' + profileId;
var startDate = getLastNdays(14); // 2 weeks (a fortnight) ago.
var endDate = getLastNdays(0); // Today.
var optArgs = {
'dimensions': 'ga:keyword', // Comma separated list of dimensions.
'sort': '-ga:sessions,ga:keyword', // Sort by sessions descending, then keyword.
'segment': 'dynamic::ga:isMobile==Yes', // Process only mobile traffic.
'filters': 'ga:source==google', // Display only google traffic.
'start-index': '1',
'max-results': '250' // Display the first 250 results.
};
// Make a request to the API.
var results = Analytics.Data.Ga.get(
tableId, // Table id (format ga:xxxxxx).
startDate, // Start-date (format yyyy-MM-dd).
endDate, // End-date (format yyyy-MM-dd).
'ga:sessions,ga:pageviews', // Comma seperated list of metrics.
optArgs);
if (results.getRows()) {
return results;
} else {
throw new Error('No views (profiles) found');
}
}
好的,我花了一段時間解決這個問題,然后才開始工作。
最好的猜測是我從Google Analytics(分析)復制了媒體資源ID錯誤。 返回並重新復制后,一切正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.