我有一个GA账户,定义了属性和视图。现在,我给了几个用户对特定视图的查看权限。如何编写/获取一个直接的URL,以便这些用户可以直接访问该视图/报告?谢谢!
首先让我们来看一个特定视图的典型报告URL:
https://analytics.google.com/analytics/web/#report/visitors-actives/a40777649w70913173p73156703/
注意模式:
BASE_URL = 'https://analytics.google.com/analytics/web/#report/'
REPORT_TYPE = 'visitors-actives/'
ACOUNT_ID = '40777649'
WEBPROPERTY_ID = '70913173'
PROFILE_ID = '73156703' # Also called the view Id.
{
"id": string,
"kind": "analytics#accountSummary",
"name": string,
"starred": boolean,
"webProperties": [
{
"kind": "analytics#webPropertySummary",
"id": string,
"name": string,
"internalWebPropertyId": string,
"level": string,
"websiteUrl": string,
"starred": boolean,
"profiles": [
{
"kind": "analytics#profileSummary",
"id": string,
"name": string,
"type": string,
"starred": boolean
}
]
}
]
}
ACCOUNT_ID
是顶层账户摘要.id
。WEBPROPERTY_ID
是账户摘要.webproperties[X].internalWebPropertyId
。PROFILE_ID
是账户摘要.webproperties[X].profiles[X].id
有了这些信息,您就可以重构URL链接,以获取特定视图的报告。
FULL_URL = BASE_URL + REPORT_TYPE + 'a' + ACCOUNT_ID + 'w' + WEBPROPERTY_ID + 'p' + PROFILE_ID + '/'
除了Matt的精彩回答外,您可以使用此处文档中的“尝试此API”部分,无需编写一行代码即可获取此信息:
还有一些代码片段可以以编程方式完成此操作。
不要忘记您需要使用具有GA访问权限的帐户登录才能使其正常工作。
我有几点要补充Matt和Adam的回答:
https://analytics.google.com/analytics/web/#/report-home/a[account id]w[internal web property id]p[view id]
重要提示:用户必须至少具有对Web属性的READ_AND_ANALYZE
权限才能访问其默认视图。internalWebPropertyId
是web properties collection中的资源,可以通过各种GA管理API调用获得。例如,我从使用insert
call创建新Web属性后的响应对象中提取了此值。