このページの Google スプレッドシート App Script にデータをインポートする Google App Script の例を使用しています。 この例は正常に動作しますが、データを取得している Web プロパティを変更したいと考えています。
例を探して、サンプル コードのさまざまな繰り返しを試しましたが、正しくありません。このコードを変更してプロファイル内の別のプロパティをプルする方法について、誰かがこのコードを手伝ってくれますか?
function runDemo() {
try {
var firstProfile = getFirstProfile();
var results = getReportDataForProfile(firstProfile);
outputToSpreadsheet(results);
} catch (error) {
Browser.msgBox(error.message);
}
}
function getFirstProfile() {
var accounts = Analytics.Management.Accounts.list();
if (accounts.getItems()) {
var firstAccountId = accounts.getItems()[0].getId();
var webProperties = Analytics.Management.Webproperties.list(firstAccountId);
if (webProperties.getItems()) {
var firstWebPropertyId = webProperties.getItems()[0].getId();
var profiles = Analytics.Management.Profiles.list(firstAccountId, firstWebPropertyId);
if (profiles.getItems()) {
var firstProfile = profiles.getItems()[0];
return firstProfile;
} else {
throw new Error('No profiles found.');
}
} else {
throw new Error('No webproperties found.');
}
} else {
throw new Error('No accounts found.');
}
}