如何使用 Google Embed API 获取选定的帐户 ID 和 属性 ID
How to obtain selected account ID and property ID with Google Embed API
我正在尝试使用 PHP 的 Google API 从 GA 中提取一些数据,包括用户选择的货币类型。
我有可用的 PHP 代码(独立),但为了提取用户选择的货币数据,我需要提取用户的 Google_Service_Analytics_Profile
并且我总共需要 3 个 ID 才能获得个人资料:$accountId
、$webPropertyId
、$profileId
。
这是我的 PHP 提取数据的代码:
// Create a connection to the GA API service
$analytics = new Google_Service_Analytics($client);
// Select the GA profile using the provided IDs
$ga_profile = $analytics->management_profiles->get($input_data->account_id, $input_data->property_id, $input_data->profile_id);
可以看出from the source,Google_Service_Analytics_ManagementProfiles_Resource::get()
方法需要上面提到的三个ID
我想使用嵌入 API 向用户显示一个选择器,以允许他们选择我为其显示数据的配置文件,并且我打算 POST 将选定的 ID 添加到我的 PHP 从 GA 中提取数据并进行处理的代码。
不幸的是,Embed API returns 的唯一 ID 似乎是 "View ID",我理解的是上面的 $profileID
,但我我不知道如何找到剩余的 $accountId
和 $webPropertyId
ID 以允许我通过 PHP API.
拉动 "Analytics Profile"
如何获取剩余的 ID?
这是我的 HTML 和 JS:http://jsbin.com/naxiyomeko/1/edit?html,js,console,output
我能够使用以下 change
事件的 Javascript 从 Google 嵌入 API ViewSelector
中获取剩余的 ID:
viewSelector.on('change', function() {
ids = {}
ids['account_id'] = viewSelector.B.fb;
ids['property_id'] = viewSelector.HC.fb;
ids['profile_id'] = viewSelector.RF.fb;
// Do something with `ids` object here...
});
已更新 JS bin:http://jsbin.com/hirapupayi/1/edit?html,js,console,output
我正在尝试使用 PHP 的 Google API 从 GA 中提取一些数据,包括用户选择的货币类型。
我有可用的 PHP 代码(独立),但为了提取用户选择的货币数据,我需要提取用户的 Google_Service_Analytics_Profile
并且我总共需要 3 个 ID 才能获得个人资料:$accountId
、$webPropertyId
、$profileId
。
这是我的 PHP 提取数据的代码:
// Create a connection to the GA API service
$analytics = new Google_Service_Analytics($client);
// Select the GA profile using the provided IDs
$ga_profile = $analytics->management_profiles->get($input_data->account_id, $input_data->property_id, $input_data->profile_id);
可以看出from the source,Google_Service_Analytics_ManagementProfiles_Resource::get()
方法需要上面提到的三个ID
我想使用嵌入 API 向用户显示一个选择器,以允许他们选择我为其显示数据的配置文件,并且我打算 POST 将选定的 ID 添加到我的 PHP 从 GA 中提取数据并进行处理的代码。
不幸的是,Embed API returns 的唯一 ID 似乎是 "View ID",我理解的是上面的 $profileID
,但我我不知道如何找到剩余的 $accountId
和 $webPropertyId
ID 以允许我通过 PHP API.
如何获取剩余的 ID?
这是我的 HTML 和 JS:http://jsbin.com/naxiyomeko/1/edit?html,js,console,output
我能够使用以下 change
事件的 Javascript 从 Google 嵌入 API ViewSelector
中获取剩余的 ID:
viewSelector.on('change', function() {
ids = {}
ids['account_id'] = viewSelector.B.fb;
ids['property_id'] = viewSelector.HC.fb;
ids['profile_id'] = viewSelector.RF.fb;
// Do something with `ids` object here...
});
已更新 JS bin:http://jsbin.com/hirapupayi/1/edit?html,js,console,output