如何使用 Cordova 实施营销活动跟踪? [英] How do I implement Campaign tracking with Cordova?
问题描述
我正在尝试在我的cordova 应用程序中实施活动跟踪,但没有成功.
I am trying to implement campaign tracking in my cordova app, but I am not having success.
我以前使用过 danwilson 插件,效果很好,但它不支持广告系列,正如我在此处看到的:
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/问题/68
所以我把我的插件改成了这个 fork:
So I changed my plugin to this fork:
https://github.com/Anu2g/google-analytics-plugin
具有广告系列跟踪功能.
Which have campaign tracking.
我目前正在 Android 中进行测试,我已将此添加到我的清单中
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>
如图所示
https://developers.google.com/analytics/devguides/集合/android/v4/campaigns
我的 UniversalAnalyticsPlugin.java 中有竞选功能
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.");
}
}
我尝试使用 Google 测试指南使其工作:
I try to make it work using the Google guide for testing:
https://developers.google.com/analytics/solutions/testing-游戏活动
我启动
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"
在我的 cmd 中,它返回
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
看起来工作正常.然后我打开我的 logcat,我打开编译的应用程序,它记录了 Thread[GAThread,5,main]: No campaign data found.
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')
但我不明白如何接收带有参数的真实 URL,而不是硬编码的 URL.
But I dont understand how do I receive the real URL with the params, not a hardcoded one.
在 Cordova 中成功实施广告系列跟踪的人可以启发我吗?
Someone who successfully have implemented Campaign tracking in Cordova can enlighten me?
提前致谢
推荐答案
经过一番研究,以及作者对插件的一些改动,答案再明显不过了:
After some research, and some changes in the plugin by this author, the answer can't be more obvious:
在插件的最新版本中:https://github.com/danwilson/google-分析插件作者为活动添加了一个未记录的功能,它无需任何修改即可工作.它在清单中添加标签,并在将广告系列链接启动到 Google Play 时起作用.
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.
一点:还显示未找到活动数据,但它有效,即使响应不是 Google 所说的响应
One point: the No campaign data found is also showed, but it works, even if the response is not the one that Google says
祝你好运
这篇关于如何使用 Cordova 实施营销活动跟踪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!