AnalyticsReceiver in Google Analytics Tracking

2019-07-22 04:29发布

问题:

In Google Analytics Tracking Ver1, it has class AnalyticsReceiver.

But when I used Google Analytics Tracking Ver2, it hasn't got AnalyticsReceiver class. I don't know which class should I use instead.

In manifest declared when use Google Analytics Tracking:

<receiver
    android:name="com.google.analytics.tracking.android.AnalyticsReceiver"
    android:exported="true" >
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

Can you help me.

回答1:

Google seems to move this class with every release. Depending on your Google Analytics SDK version, the value for android:name will change. Here's all of the various versions for anyone else upgrading beyond v2.

Google Analytics SDK v2: com.google.analytics.tracking.android.CampaignTrackingReceiver

<receiver
    android:name="com.google.analytics.tracking.android.CampaignTrackingReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

Google Analytics SDK v3: com.google.android.apps.analytics.AnalyticsReceiver

<receiver
    android:name="com.google.android.apps.analytics.AnalyticsReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

Google Analytics SDK v4: com.google.android.gms.analytics.CampaignTrackingReceiver

<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>