针对cordova的Google广告系列

时间:2017-04-06 14:20:50

标签: android cordova google-analytics google-analytics-android

我想跟踪使用cordova开发的应用的安装源。

我正在使用此插件https://github.com/danwilson/google-analytics-plugin/

deviceReady回调中有这段代码:

 window.ga.startTrackerWithId('UA-xxxxxxxx-y', 30)
                  .then(function(){
                      console.log('Google analytics is ready now');
                      //the component is ready and you can call any method here
                      GoogleAnalytics.debugMode();
                      GoogleAnalytics.setAllowIDFACollection(true);
                  })
                .catch(e => console.log('Error starting GoogleAnalytics', e));

此处还有application中的AndroidManifest.xml标记内容:

<receiver android:name="cordova.plugins.Diagnostic$LocationProviderChangedReceiver">
        <intent-filter>
            <action android:name="android.location.PROVIDERS_CHANGED" />
        </intent-filter>
    </receiver>
    <receiver android:enabled="true" android:exported="true" android:name="com.google.android.gms.analytics.CampaignTrackingReceiver">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <service android:enabled="true" android:exported="false" android:name="com.google.android.gms.analytics.CampaignTrackingService" />
    <receiver android:enabled="true" android:name="com.google.android.gms.analytics.AnalyticsReceiver">
        <intent-filter>
            <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
        </intent-filter>
    </receiver>
    <service android:enabled="true" android:exported="false" android:name="com.google.android.gms.analytics.AnalyticsService" />

在关注Google指南并使用此link进行测试后,我得到了Broadcast completed: result=0,所以一切都应该没问题。

同样在此SO post中,它表示“作者为广告系列添加了未记录的功能,并且无需任何修改即可运行。它会在清单中添加标记,并在Google Play上启用广告系列链接时有效“。意味着一切都是自动完成的,但事实并非如此!

我是否在此过程中遗漏了某些内容,或者是否有办法获取deviceReady回调中的网址并使用类似window.ga.trackView('Screen Title', 'my-scheme://content/1111?utm_source=google&utm_campaign=my-campaign')的内容???

谢谢。

1 个答案:

答案 0 :(得分:0)

我终于找到了,

整个插件工作正常,但为了让谷歌广告系列工作,我需要安装&#34; Google Play Services SDK&#34;在建筑机器上。其余的都是在引擎盖下完成的。