Google 科尔多瓦运动

Google campaign for cordova

我想跟踪使用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,所以一切都应该没问题。

同样在这个 中它说 "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." 意味着一切都是自动完成的,但它不是!

我是不是在这个过程中遗漏了一些东西,或者有没有办法在 deviceReady 回调中获取 url 并只使用类似 window.ga.trackView('Screen Title', 'my-scheme://content/1111?utm_source=google&utm_campaign=my-campaign') 的东西???

谢谢。

终于找到了,

整个插件运行良好,但为了使 google 广告活动正常运行,我需要在构建机器上安装 "Google Play Services SDK"。其余的在幕后完成。