如何使用Cordova实施广告系列跟踪? [英] How do I implement Campaign tracking with Cordova?

查看:262
本文介绍了如何使用Cordova实施广告系列跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的科尔多瓦应用中实施广告系列跟踪,但我没有取得成功。我以前使用过danwilson插件,该插件效果不错,但确实如此不支持广告系列,正如我在此处看到的那样:



https://github.com/danwilson/google-analytics-plugin/issues/68



所以我改变了我的插件到这个分支:



https:// github.com/Anu2g/google-analytics-plugin



其中有广告系列跟踪。



我目前正在Android中进行测试,我已将其添加到我的清单中

 <! - 用于Google Play商店广告系列衡量 - > 
< service android:name =com.google.android.gms.analytics.CampaignTrackingService/>
< receiver android:name =com.google.android.gms.analytics.CampaignTrackingReceiver
android:exported =true>
< intent-filter>
< / intent-filter>
< / receiver>



https://developers.google.com/analytics/devguides/collection/android/v4 /广告系列



我在UniversalAnalyticsPlugin.java中添加了广告系列功能

  private void trackView(String screenname,String deepLinkUrl,CallbackContext callbackContext){
if(!trackerStarted){
callbackContext.error(Tracker not started);
return;
}

addCustomDimensionsToTracker(tracker); (null!= screenname&&& screenname.length()> 0){
tracker.setScreenName(screenname);


tracker.send(新的HitBuilders
.ScreenViewBuilder()
.setCampaignParamsFromUrl(deepLinkUrl)
.build()
);
callbackContext.success(Track Screen:+ screenname);
} else {
callbackContext.error(Expected one non-empty string argument。);
}
}

我尝试使用Google指南测试:

https: //developers.google.com/analytics/solutions/testing-play-campaigns



我推出

  adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.my.app/com.google.android.gms.analytics.CampaignTrackingReceiver --esreferrer utm_source%3DtestSource%26utm_medium%3DtestMedium%26utm_term%3DtestTerm%26utm_content%3DtestContent%26utm_campaign%3DtestCampaign

在我的CMD中,它返回

 广播:意图{act = com.android.vending.INSTALL_REFERRER cmp = com.my。 app / com.google.android.gms.analytics.CampaignTrackingReceiver(有额外功能)} 
广播完成:结果= 0

看起来工作正常。然后我打开我的logcat,打开编译的应用程序,它记录 Thread [GAThread,5,main]:找不到任何广告系列数据。



正如我在插件文档中看到的,我必须这样做:

 要跟踪屏幕PageView)w / campaign detilas:

window.analytics.trackView('屏幕标题','my-scheme:// content / 1111?utm_source = google& utm_campaign = my-campaign')

但我不明白我如何使用params接收真正的URL,而不是硬编码的。



在科尔多瓦成功实施Campaign跟踪的人可以启发我吗?

预先感谢

解决方案

经过一些研究,以及本作者对插件的一些更改,答案不会更明显:



在插件的最新版本中: https://github.com/danwilson /谷歌,analyti cs-plugin ,作者为广告系列添加了未公开的功能,并且无需任何修改即可使用。它会在清单中添加标签,并在广告系列链接启动至Google Play时起作用。

,即使回应不是Google所说的回应



祝你好运

I am trying to implement campaign tracking in my cordova app, but I am not having success.

I previously used danwilson plugin, which works nice, but it does not have support for campaigns, as I saw here:

https://github.com/danwilson/google-analytics-plugin/issues/68

So I changed my plugin to this fork:

https://github.com/Anu2g/google-analytics-plugin

Which have campaign tracking.

I am currently testing in Android, I have added this to my manifest

    <!-- Used for Google Play Store Campaign Measurement-->
<service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
          android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

As is shown in

https://developers.google.com/analytics/devguides/collection/android/v4/campaigns

And I have the campaign function in my UniversalAnalyticsPlugin.java

private void trackView(String screenname, String deepLinkUrl, CallbackContext callbackContext) {
    if (! trackerStarted ) {
        callbackContext.error("Tracker not started");
        return;
    }

    addCustomDimensionsToTracker(tracker);

    if (null != screenname && screenname.length() > 0) {
        tracker.setScreenName(screenname);
        tracker.send(new HitBuilders
                .ScreenViewBuilder()
                .setCampaignParamsFromUrl(deepLinkUrl)
                .build()
                );
        callbackContext.success("Track Screen: " + screenname);
    } else {
        callbackContext.error("Expected one non-empty string argument.");
    }
}

I try to make it work using the Google guide for testing:

https://developers.google.com/analytics/solutions/testing-play-campaigns

I launch

adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.my.app/com.google.android.gms.analytics.CampaignTrackingReceiver --es "referrer" "utm_source%3DtestSource%26utm_medium%3DtestMedium%26utm_term%3DtestTerm%26utm_content%3DtestContent%26utm_campaign%3DtestCampaign"

In my cmd, and it returns

    Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=com.my.app/com.google.android.gms.analytics.CampaignTrackingReceiver (has extras) }
Broadcast completed: result=0

Which looks to work fine. Then I open my logcat, I open the compiled app, and it logs Thread[GAThread,5,main]: No campaign data found.

As I see in the plugin docs, I have to do this:

To track a Screen (PageView) w/ campaign detilas:

window.analytics.trackView('Screen Title', 'my-scheme://content/1111?utm_source=google&utm_campaign=my-campaign')

But I dont understand how do I receive the real URL with the params, not a hardcoded one.

Someone who successfully have implemented Campaign tracking in Cordova can enlighten me?

Thanks in advance

解决方案

After some research, and some changes in the plugin by this author, the answer can't be more obvious:

in the last revision of the plugin: https://github.com/danwilson/google-analytics-plugin the author added an undocumented functionality for campaigns, and it works without any modification. It add the tags in the manifest and it works when a campaign link is launched to Google Play.

One point: the No campaign data found is also showed, but it works, even if the response is not the one that Google says

Good luck

这篇关于如何使用Cordova实施广告系列跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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