我正在尝试使用Google API for PHP从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);
从来源中可以看出,Google_Service_Analytics_ManagementProfiles_Resource::get()
方法需要上述三个ID。
我想使用嵌入式API向用户显示一个选择器,允许他们选择我显示数据的配置文件,我打算将所选的ID POST到我的PHP代码中,该代码从GA中提取数据并对其进行处理
不幸的是,Embed API返回的唯一ID似乎是"查看ID",我知道它是上面的$profileID
,但我不知道如何找到剩余的$accountId
和$webPropertyId
ID,以便通过PHP API提取"分析配置文件"。
如何获取剩余的ID?
这是我的HTML和JS:http://jsbin.com/naxiyomeko/1/edit?html,js,控制台,输出
我能够使用以下用于change
事件的Javascript从Google Embed 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,控制台,输出