を使用してデータを取得します。私は私のプロパティデータにアクセスするために私の開発者の電子メールアドレスの許可を設定しました。 7のうちGoogle AnalyticsのレポートAPI v3には、私は例えば<strong>ページビュー</strong>、<strong>ユーザー</strong>、<strong>直帰率</strong>などGoogleアナリティクスのデータをつかむために、サービスアカウントを持っているPHP
、私は5プロパティ/サイトのデータをつかむことができていますが、他の2 両方がGoogle Analyticsの管理>ユーザー管理のアクセス権限を持っているアカウントが
に動作していません。私はPHPのGoogle Analytics V3
を使用しています。以下は私が使用したコードの一部です。
$account_id = 'ga:343434334'; // my view id goes here
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$key = file_get_contents($key_file_location);
// seproate additional scopes with a comma
$scopes ="https://www.googleapis.com/auth/analytics.readonly";
$cred = new Google_Auth_AssertionCredentials(
$Email_address,
array($scopes),
$key
);
$client->setAssertionCredentials($cred);
if($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$service = new Google_Service_Analytics($client);
// get page threshold
$optParams1 = array(
'dimensions' => 'ga:pageDepth',
'sort' => '-ga:users',
'filters' => 'ga:[email protected]',
'max-results' => '1'
);
$results1 = $service->data_ga->get($account_id, $start_date, $end_date, 'ga:users', $optParams1);
print '<pre>';
print_r(results1);
printt '</pre>';
あなたの答えをありがとう、私はアカウントレベルの私の許可を持っていた。私は問題を実際に持っていましたが、私はGAからデータを得ることができないと思っていましたが、理由は "私はメトリックをフィルタリングしていました。ありがとう:) –