从 Google 分析中检索 Android 应用程序的统计数据
Retrieve stats from Google Analytics for Android App
我已将 Google 分析集成到我的 Android 应用程序中。该应用程序是一个照片打印应用程序,其中包含一组用户可以选择的预定义主题。但是,是否可以使用某些 api 而不是使用 Google Analytics 控制台从 Google Analytics(例如,用户选择的前 5 个主题)检索统计信息?
您可以在 Google Analytics 中创建一个可以有效跟踪此事件的事件。事件具有类别、操作、标签和事件值。因此,您可以相当有效地添加主题或任何您想要的动态值。然后,您就可以在 Google 事件类别的分析中进行搜索和排序,并找到使用最多的主题
@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 列中看到每个事件的输入次数,这应该会为您提供所需的信息
您要检索的信息是 Core Reporting API. Because the Google Analytics API requires all requests to be authenticated and your users are not authorized to access your Google Analytics account It is probably best to set up the API call on the server side using a service account here is an example of how to set up a 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 请求的结果的类似问题。
我已将 Google 分析集成到我的 Android 应用程序中。该应用程序是一个照片打印应用程序,其中包含一组用户可以选择的预定义主题。但是,是否可以使用某些 api 而不是使用 Google Analytics 控制台从 Google Analytics(例如,用户选择的前 5 个主题)检索统计信息?
您可以在 Google Analytics 中创建一个可以有效跟踪此事件的事件。事件具有类别、操作、标签和事件值。因此,您可以相当有效地添加主题或任何您想要的动态值。然后,您就可以在 Google 事件类别的分析中进行搜索和排序,并找到使用最多的主题
@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 列中看到每个事件的输入次数,这应该会为您提供所需的信息
您要检索的信息是 Core Reporting API. Because the Google Analytics API requires all requests to be authenticated and your users are not authorized to access your Google Analytics account It is probably best to set up the API call on the server side using a service account here is an example of how to set up a 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 请求的结果的类似问题。