Android - Google Analytics管理器,包含Google Analytics和Firebase Analytics [英] Android - Google tag Manager with Google Analytics and Firebase Analytics

查看:315
本文介绍了Android - Google Analytics管理器,包含Google Analytics和Firebase Analytics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用购物应用,并希望跟踪我的移动应用中发生的事件。我的目标是使用Firebase Analytics和Google跟踪代码管理器跟踪事件,并将相同的事件推送到Google分析。



我的活动> Firebase> Google代码管理器> Google Analytics



我按照以下指南将Google代码管理器和Firebase分析集成到我的应用程序中。






  • 由于没有屏幕实际名称的屏幕视图没有多大意义,我们也必须包含该名称。选择更多设置 - 要设置的字段并添加新字段。 screenName是用于Google Analytics的值,我将解释下一个使用的变量。我选择将我的标签命名为Screen Tracking。您的设置应如下所示:





{{Item Name}}是另一个变量,就像之前创建的跟踪ID常量一样。它利用Firebase推送其事件的数据层。在我的情况下,我决定像这样使用Firebase来跟踪我的主屏幕:

  Bundle bundle = new Bundle(); 
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME,home);
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM,bundle);

这将向view_item事件发送一个包含屏幕名称的参数item_name到Firebase。如果要跟踪不同的事件和参数,则必须分别使用这些事件和参数名称。因此,要使用上面显示的代码跟踪我的屏幕,我将使用关键字view_item和item_name。




  • 我创建了一个新的变量标记管理器,将其命名为项目名称,并选择它应具有item_name的值。有了这个,我可以访问参数值并将正确的屏幕名称发送到Google Analytics。




配置我的代码管理器帐户以将firebase事件推送到Google Analytics。





  • 现在,完成我们跟踪的所有操作都是设置触发器。触发器定义标记触发的时间。为了将您的Firebase活动跟踪到Google Analytics,您应该选择每次特定事件发生时触发的触发器。



这里我使用事件名称,这是一个预定义变量,每次将新的view_item事件推送到数据层时触发此标记。






  • 使用此触发器,设置完成。每次发生view_item事件时,跟踪代码管理器都会触发此标记。它将从item_name中取出值,并将其作为屏幕视图发送给Google Analytics。





就是这样!您现在要做的是发布容器,下载容器并将其添加到项目中。如果你确实搞错了,别担心。您只需编辑和发布新版本 - 跟踪代码管理器将在24小时内自行更新。



注意: 之后仍然可以配置Google Analytics跟踪,而无需更改任何代码。



希望这会有所帮助!!!


I am working with a shopping app and would like to track so events occuring on my mobile application. My objective is to track the events using Firebase Analytics and Google Tag manager and push the same events to Google analytics.

My event > Firebase > Google tag manager > Google analytics

I followed the below guide to integrate Google tag manager and Firebase analytics to my application.

https://developers.google.com/tag-manager/android/v5/

I was able to log my events on Firebase console and view in debug console. I have added dependency for Tag manager in my gradle so that the events are Send to tag manager also.

Now i would like to know, how can i push those events from Google tag manager to Google analytics? Can someone provide me insights into configuring tags and triggers on Tag manger and Google analytics

My Android code for logging events is as below

 public void logEventClicked(View view){
    Toast.makeText(this, "Logging event", Toast.LENGTH_SHORT).show();
    Bundle bundle = new Bundle();
    bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "150");
    mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_TO_CART, bundle);
}

解决方案

Well, I got all this information from AndroidStuff Blog written by @DavidMedenjak in any case this link got expired I am posting some extract and Images from his blog....

how can i push those events from Google tag manager to Google analytics? Can someone provide me insights into configuring tags and triggers on Tag manger and Google analytics

  • In your Tag Manager Console open your container and click to add a new tag, either by selecting the option on the dashboard or the tag menu entry. The product to use is Google Analytics and after selecting it you will be prompted for your Tracking ID. Select the button to the right and choose to create a new variable. It is a good idea to have your Tracking ID as a constant value.

  • Since having screen views without the actual name of the screen does not make too much sense, we will have to include the name as well. Select More Settings - Fields to Set and add a new field. screenName is the value to use with Google Analytics, I’ll explain the variable used next. I chose to name my tag Screen Tracking. Your setup should look something like this:

{{Item Name}} is another variable like the Tracking ID Constant created before. It makes use of the data layer where Firebase pushes its events. In my case I decided to use Firebase like this to track my home screen:

    Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "home");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle);

This will send a view_item event with a parameter item_name containing the screen name to Firebase. If you want to track different events and parameters you have to use those event and parameter names respectively. So to track my screens with the code shown above I’m going to use the keys view_item and item_name.

  • I create a new variable in Tag Manager, name it Item Name and select that it should have the value of item_name. With this I can access the parameter value and send the correct screen name to Google Analytics.

configure my tag manager account to Push firebase events to Google analytics.

  • Now, all that’s left to finish our tracking is to set up a trigger. Triggers define when your tag fires. For the purpose of tracking your Firebase Events to Google Analytics as well you should choose a trigger that fires every time a specific event occurs.

Here I use Event Name which is a predefined variable to fire this tag every time a new view_item event gets pushed to the data layer.

  • With this trigger the setup is complete. Every time a view_item event occurs, Tag Manager will fire this tag. It will take the value out of item_name and send it as a screen view to Google Analytics.

That’s it! What you want to do now is publish your container, download it and add it to your project. If you did get something wrong, don’t worry. You can just edit and publish a new version—Tag Manager will update itself within 24 hours.

Note: Google Analytics tracking can still be configured afterwards without changing any of your code.

Hope this helps!!!

这篇关于Android - Google Analytics管理器,包含Google Analytics和Firebase Analytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆