How to configure Android Google Tag Manager v4 with Google Analytics (Universal Analytics)

大兔子大兔子 提交于 2019-11-28 02:09:49

问题


I'm trying to use Google Tag Manager to report screenviews and events to Google Analytics. I followed the google's tutorial but I'm not able to even report the screenviews. Also spent hours searching in google but there was no match. Almost all the information available is for Android's v3 or the old GTM web interface.

This is my configuration

Pushing the event to the data layer throws no error. However screenName seems not been sent.

Java code

public static void pushScreenViewEvent(@NonNull Context context, @NonNull String screenName) {
    DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
    dataLayer.pushEvent("screenView",
            DataLayer.mapOf("screenName", screenName));
}

Debug log after push data

02-23 19:12:39.376  31787-31888/com.example.debug V/GoogleTagManager﹕ Sending hit to service   PATH: https:  PARAMS: sr=1080x1776,  a=558676027,  v=1,  ht=1424686354314,  an=Example app,  ul=ja-jp,  t=appview,  _u=.L,  tid=UA-XXXXXX-1,  cid=XXXXXX,  aid=com.example.debug,  av=1.0.0,

Google Play Services version

compile 'com.google.android.gms:play-services-base:6.5.87'

There's this tutorial but it is for the old GTM v3 with the old GTM web screenshots https://developers.google.com/tag-manager/android/v3/ua#screenviews


回答1:


Ok, it was my fault. There was two problems.

  1. Fields to set were wrong In order to track the screen in GA it's necessary to set the Screen Name's Measurement protocol parameter &cd
    In my case Client Id and User Id are also necessary, that's why I send &ci and &uid

  2. I was using a default binary container from a different test account. After use the correct container it worked like a charm.




回答2:


It seems like firing rule is incorrect. Try something like {{event}} equals screenView or Always as firing rule. And it will take 24hrs to update in the Google Analytics dashboard, so it will not appear in the real time. Let me know if it doesn't work.



来源:https://stackoverflow.com/questions/28672360/how-to-configure-android-google-tag-manager-v4-with-google-analytics-universal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!