简体   繁体   English

使用Google Analytics跟踪变量

[英]Tracking a variable using Google Analytics

I'm extremely new to Google Analytics on Android. 我对Android上的Google Analytics非常陌生。

I've searched quite a bit for this, but I'm not sure I have understood it correctly, but here goes : 我已经搜索了很多,但我不确定我是否理解它,但是这里有:

I want Google Analytics to track a particular variable in my app. 我希望Google Analytics跟踪我应用中的特定变量。

So for instance, a variable a has a separate value for every user of the app, is it possible for me to display the average of the value of the variable in a Google Analytics dashboard ? 例如,变量a对应用的每个用户都有一个单独的值,我是否可以在Google Analytics信息中心中显示变量值的平均值?

As per my understanding goes, we can do this using Custom Dimensions and Metrics. 根据我的理解,我们可以使用自定义维度和指标来完成此操作。

I haven't been able to find any tutorial for the same. 我一直无法找到相同的教程。

I'd be grateful if someone could help me with a tutorial or point me to something other than the developer pages from Google. 如果有人可以帮助我学习教程或者指向Google以外的其他内容,我将不胜感激。

Thank You! 谢谢!

It is possible to send additional data to Google Analytics, using either Custom Dimensions or Custom Metrics. 可以使用自定义维度或自定义指标向Google Analytics发送其他数据。

Custom Dimensions are used for labels and identifiers that you will later use to separate your data. 自定义维度用于以后用于分隔数据的标签和标识符。 For example, you might have a Custom Dimension that tracks log-in status. 例如,您可能有一个跟踪登录状态的自定义维度。 This would allow you to break down your reports and compare logged-in traffic to not logged-in. 这样您就可以分解报告并将登录的流量与未登录的流量进行比较。 These can contain text; 这些可以包含文字; while AB testing your site you might set up a custom dimension with the options 'alpha' and 'beta'. 在AB测试您的网站时,您可以设置一个自定义维度,其中包含“alpha”和“beta”选项。 They can also contain numeric values, such as the time '08:15', or a unique identifier that you've generated (although you should be careful to follow Google's advice here, lest you include PII and rick account deletion https://developers.google.com/analytics/solutions/crm-integration#user_id ). 它们还可以包含数字值,例如时间'08:15',或者您生成的唯一标识符(尽管您应该谨慎遵循Google的建议,以免您包含PII和rick帐户删除https:// developers.google.com/analytics/solutions/crm-integration#user_id )。

Custom Metrics are used for numeric variables such as engagement time, or shopping cart value. 自定义指标用于数字变量,例如参与时间或购物车价值。 They are a lot like custom dimensions, but are intended to be compared across dimensions. 它们很像自定义尺寸,但可以跨尺寸进行比较。 For example, you could compare the shopping basket value of your Organic users to those who come in via a paid link. 例如,您可以将有机用户的购物篮价值与通过付费链接进入的用户进行比较。

If you wanted to calculate an average, you would also require a calculated metric. 如果您想计算平均值,则还需要计算度量标准。 This takes two metrics you already have, and produces a third. 这需要您已经拥有的两个指标,并产生第三个指标。 For example, if you site was all about instant engagement, and you wanted to track the time before the first click event on each page, you could set up that event click time as a custom metric. 例如,如果您的网站完全是即时参与,并且您希望跟踪每个页面上第一次点击事件之前的时间,则可以将该事件点击时间设置为自定义指标。 But this would only tell you what the total is; 但这只会告诉你总数是多少; surely more customers are a good thing, but they make that total go up! 肯定会有更多的客户是好事,但他们总是让这个客户上升! So you set up a calculated metric that divides this total by the number of page views, giving you a value per page viewed. 因此,您需要设置一个计算指标,将此总计除以页面查看次数,从而为每个查看的页面提供值。

There's a great guide by Simo Ahava about tracking Content Engagement that includes instructions for setting up Custom Metrics and Calculated Metrics. Simo Ahava提供了一个关于跟踪内容参与的精彩指南,其中包括有关设置自定义指标和计算指标的说明。 http://www.simoahava.com/analytics/track-content-engagement-part-2/ http://www.simoahava.com/analytics/track-content-engagement-part-2/

However, I should warn you that his guide uses Google Tag Manager, which greatly simplifies the process of adding such customisation to your tags. 但是,我应该警告您,他的指南使用Google跟踪代码管理器,这极大地简化了向代码添加此类自定义的过程。 If you don't want to take that step, you will have to code it manually, as recommended by Google's support https://support.google.com/analytics/answer/2709828?hl=en 如果您不想采取这一步骤,则必须按照Google支持的建议手动对其进行编码https://support.google.com/analytics/answer/2709828?hl=zh-CN

UPDATE UPDATE

Firebase Analytics is now Google's recommended solution for mobile app analytics. Firebase Analytics现在是Google推荐的移动应用分析解决方案。 It's user and event-centric and comes with unlimited app event reporting, cross-network attribution, and postbacks. 它以用户和以事件为中心,并提供无限的应用事件报告,跨网络归因和回发。


Older Answer 较旧的答案

You may use GA Event Tracking 您可以使用GA 事件跟踪

Check this guide and this one to check rate limits before you try this. 检查本指南这一个检查速率限制您尝试在此之前。

Events are a useful way to collect data about a user's interaction with interactive components of your app, like button presses or the use of a particular item in a game. 事件是收集用户与应用程序的交互式组件交互的数据的有用方式,例如按钮按下或在游戏中使用特定项目。

An event consists of four fields that you can use to describe a user's interaction with your app content: 事件包含四个字段,您可以使用这两个字段来描述用户与您的应用内容的互动:

Field Name Type Required Description Category String Yes The event category Action String Yes The event action Label String No The event label Value Long No The event value Field Name Type Required Description Category String Yes The event category Action String Yes The event action Label String No The event label Value Long No The event value

To send an event to Google Analytics, use HitBuilders.EventBuilder and send the hit, as shown in this example: 要将事件发送到Google Analytics,请使用HitBuilders.EventBuilder并发送HitBuilders.EventBuilder ,如以下示例所示:

// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
    TrackerName.APP_TRACKER);
// Build and send an Event.
tracker.send(new HitBuilders.EventBuilder()
    .setCategory("Achievement")
    .setAction("Earned")
    .setLabel("5 Dragons Rescued")
    .setValue(1)
    .build());

On GA console you can see something like this: 在GA控制台上,您可以看到如下内容: 在此输入图像描述

where event value is 事件值是什么

在此输入图像描述

and avg value is 和平均值是

在此输入图像描述


If you want to track users with specific attributes/traits/metadata then custom dimensions can be used to send this type of data to Google Analytics. 如果您要跟踪具有特定属性/特征/元数据的用户,则可以使用自定义维度将此类数据发送到Google Analytics。

See Set up or edit custom dimensions (Help Center) and then update the custom dimension value as follows: 请参阅设置或编辑自定义维度(帮助中心) ,然后按如下所示更新自定义维值:

 // Get tracker.
 Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
    TrackerName.APP_TRACKER);
 t.setScreenName("Home Screen");

 // Send the custom dimension value with a screen view.
 // Note that the value only needs to be sent once.
 t.send(new HitBuilders.ScreenViewBuilder()
    .setCustomMetric(1, 5)
    .build()
 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM