我已将Google Analytics集成到我的Android应用中。该应用程序是一个照片打印应用程序,其中包含一组用户可以选择的预定义主题。但是,是否可以使用某些API而不是使用Google Analytics控制台从Google Analytics(例如,用户选择的前5个主题)中检索统计信息?
答案 0 :(得分:1)
您要查找的信息是Core Reporting API。由于Google AnalyticsAPI要求对所有请求进行身份验证,而您的用户不authorized才能访问您的Google Analytics帐户,最好使用服务帐户在服务器端设置API调用,这是一个示例如何设置python application以使用服务帐户访问API。
但您的查询应该是什么?
analytics.data().ga().get(
ids='ga:' + profile_id,
start_date='30daysAgo',
end_date='today',
metrics='ga:totalEvents',
dimensions='ga:eventLabels').execute()
您的应用程序需要一种从您自己的服务器访问查询结果的方法。您可能还希望使用Google Analytics Super Proxy来解决类似的问题,即允许外部用户访问经过身份验证的API请求的结果。
答案 1 :(得分:0)
您可以在Google Analytics中创建一个有效跟踪此事件的活动。事件包含类别,操作,标签和事件值。因此,您可以相当有效地添加主题或任何您想要的动态值。然后,您就可以在Google Analytics中搜索和排序事件类别,并找到最常用的主题
@Override
public void themeSelected(String theme) {
// May return null if a Tracker has not yet been initialized with a
// property ID.
Tracker tracker = Tracker.getInstance(this);
// that are set and sent with the hit.
tracker.send(MapBuilder
.createEvent("Theme", // Event category (required)
"Theme Selected", // Event action (required)
theme, // Event label - Can dynamically set this with the theme that was selected so you can search in Google Analytics on it.
null) // Event value
.build()
);
}
屏幕截图显示事件标签的排序。我的标签是用户输入的数字。请注意,您可以在TotalEvents列中查看每个输入的次数,该列应该为您提供所需的信息