我如何使用setCampaignParamsFromUrl设置广告与谷歌Analytics(分析)() [英] How can I set campaign with Google Analytics using setCampaignParamsFromUrl()

查看:1220
本文介绍了我如何使用setCampaignParamsFromUrl设置广告与谷歌Analytics(分析)()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新

这是由错误,谷歌已经定格在发布4.5版 - 谷歌播放服务7.3(2015年5月1日)。当使用谷歌播放服务7.3或更高版本应该可以调用 setCampaignParametersFromUrl()与预期的完整URL。

This was caused by a bug that Google have fixed in "Release Version 4.5 - Google Play Services 7.3 (May 1, 2015)". When using Google Play Services 7.3 or later it should be possible to call setCampaignParametersFromUrl() with a full URL as expected.

原题

我在我的Andr​​oid应用使用谷歌Analytics(分析)V4。在启动的时候我送打谷歌分析屏幕视图,我把我的<一运动参数href=\"https://developer.android.com/reference/com/google/android/gms/analytics/HitBuilders.ScreenViewBuilder.html\"相对=nofollow> HitBuilders.ScreenViewBuilder 通过调用<一个href=\"https://developer.android.com/reference/com/google/android/gms/analytics/HitBuilders.HitBuilder.html#setCampaignParamsFromUrl(java.lang.String)\"相对=nofollow> setCampaignParamsFromUrl() 是这样的:

I'm using Google Analytics V4 in my Android app. On startup I send a screen view hit to Google Analytics and I set the campaign parameters on my HitBuilders.ScreenViewBuilder by calling setCampaignParamsFromUrl() like this:

String url = "http://example.com/?referrer=utm_source%3Down-build%26utm_campaign%3Dinternal-testing";
builder.setCampaignParamsFromUrl(url); 

看起来这是工作,因为我可以看到,活动包括在从谷歌分析日志:

It seems like this is working because I can see that the campaign is included in the logs from Google Analytics:

V/GAV4﹕ Thread[GAThread,5,main]: Sending hit to service ...,  cn=internal-testing...

然而,当我看着我的谷歌分析网络界面,第二天这项运动不显示数据。我只是有活动的用户(未设置)。

However when I'm looking at my data at the Google Analytics web interface the next day this campaign does not show up. I only have users with campaign "(not set)".

我已经卸载了我的应用程序,清除了广告的id和重新安装应用程序,我看到这个安装,如在谷歌Analytics(分析)网络界面的新用户,所以我知道数据被送往那里。但是我用的是运动不出来。

I've uninstalled my app, cleared the advertising id and re-installed the app and I see this installation as a new user in the Google Analytics web interface so I know the data is sent there. But the campaign I use does not show up.

我使用 setCampaignParamsFromUrl()或错我错过了什么东西?我必须配置我有什么地方活动或应谷歌分析拿起值之前自动新的广告活动还没有见过?

Am I using setCampaignParamsFromUrl() wrongly or have I missed something else? Do I have to configure the campaigns I have somewhere or should Google Analytics pick up values it hasn't seen before as new campaigns automatically?

(至于为什么我不听安装参照事件看:<一href=\"http://stackoverflow.com/questions/28874399/what-is-the-scope-of-the-utm-campaign-dimension-in-google-analytics-v4-on-androi/28883267#28883267\">What是utm_campaign尺寸在Android谷歌Analytics(分析)V4?)

(As for why I'm not listening to the install referrer event see: What is the scope of the utm_campaign dimension in Google Analytics v4 on Android?)

推荐答案

更新:的问题596 已得到修复由谷歌,现在可以叫 setCampaignParamsFromUrl()使用时用URL谷歌播放服务的最新版本(7.3发布2015年5月1日)

Update: issue 596 have been fixed by Google, it is now possible to call setCampaignParamsFromUrl() with a URL when using the latest version of Google Play Services (7.3 released May 1st 2015)

一些测试我设法弄清楚是怎么回事,并经过什么格式进行传递的URL <一个href=\"https://developer.android.com/reference/com/google/android/gms/analytics/HitBuilders.HitBuilder.html#setCampaignParamsFromUrl(java.lang.String)\"相对=nofollow> setCampaignParamsFromUrl() 应该有。

After some testing I managed to figure out what is going on and exactly what format the URL passed to setCampaignParamsFromUrl() should have.

TL; DR:使用生成一个URL的<一个href=\"https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#google-play-url-builder\"相对=nofollow>谷歌Play网址构建器,但仅传递引用字符串(后部分引用= ),以 setCampaignParamsFromUrl()

TL;DR: Generate an URL using the Google Play URL Builder, but pass only the referrer string (part after referrer=) to setCampaignParamsFromUrl().

setCampaignParamsFromUrl()被称为启动了服用后的一切'?'和分裂它在每个'和;'得到它应该送到GA所有参数的清单。

When setCampaignParamsFromUrl() is called it starts by taking everything after the '?' and splitting it on each '&' to get a list of all parameters it should send to GA.

有关每个参数它然后分割上=,并执行第一子串作为参数和第二为该参数值

For each parameter it then splits on '=' and takes the first substring as parameter and the second as value for that parameter.

通常这工作不错,但它并不由谷歌产生Play网址构建网址。之后取消转义原来的问题使用的URL的参数字符串我们得到的字符串:

Normally this works good, but it does not work for URLs generated by the Google Play URL builder. After un-escaping the parameter string of the URL used in the original question we get the string:

referrer=utm_source=own-build&utm_campaign=internal-testing

在拆分后'和;'我们得到以下两个字符串

After splitting on '&' we get the following two strings

1. referrer=utm_source=own-build
2. utm_campaign=internal-testing

其中, utm_campaign 被分配内部测试的价值,但第一个是有问题的。第二,可以很好地处理。在那里,我们得到的参数引用值为utm_source。由于引用是不是不报GA,既然utm_source是必需的参数GA会把这项运动数据为无效,并忽略所有报告的其他参数的有效运动参数在同一时间

The second can be handled nicely where utm_campaign gets assigned the value "internal-testing", but the first is problematic. There we get the parameter referrer with the value "utm_source". Since referrer is not a valid campaign parameter it is not reported to GA, and since utm_source is a required parameter GA will treat this campaign data as invalid and ignore all the other parameters reported at the same time.

因此​​,要获得 setCampaignParamsFromUrl()来工作,你可以只在引用字符串传递,这是一切后,引用= 由谷歌Play网址构建器生成的URL。因此,在原来的问题使用的URL应

So to get setCampaignParamsFromUrl() to work you can pass in only the referrer string, that is everything after referrer= in the URL generated by the Google Play URL Builder. So the URL used in the original question should be

utm_source%3Down-build%26utm_campaign%3Dinternal-testing

这是不是需要在所有自GA SDK自动拿起包由网址构建器生成的URL的一部分的包名。

The package name that is part of the URL generated by the URL builder is not needed at all since the GA SDK picks up the package automatically.

由于这种行为感觉对我来说这已经报道的问题596 在GA bug跟踪系统。

Since this behavior feels like a bug to me this has been reported as issue 596 in the GA bug tracker.

这篇关于我如何使用setCampaignParamsFromUrl设置广告与谷歌Analytics(分析)()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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