16

I am using Google analytics v4 in my android app. The install tracking was working fine for some days and all of a sudden my broadcast receiver is not registered.

Logcat says : CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.

This is what I have done within my Manifest application tag:

    <service android:name="com.google.android.gms.analytics.CampaignTrackingService"
        android:enabled="true"
     android:exported="false" />
    <receiver
        android:name="my.package.CustomCampaignTrackingReceiver"
        android:exported="true" >
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>

And my custom campaign tracking receiver looks like this:

public class CustomCampaignTrackingReceiver extends BroadcastReceiver {

  @Override
  public void onReceive(Context context, Intent intent) {

    // When you're done, pass the intent to the Google Analytics receiver.
        new CampaignTrackingReceiver().onReceive(context, intent);

        Log.v("ReferralReceiver", " " + intent.getAction());
        Log.v("ReferralReceiver", " " + intent.getDataString());
        Log.v("ReferralReceiver", " " + intent.toString());
        Log.v("ReferralReceiver", " " + intent.getStringExtra("referrer"));

        //call to other referrers

  }
}

I am not able to figure out where things are going out of hand. I am using only one INSTALL_REFERRER filter in my manifest.

pixelscreen
  • 1,945
  • 2
  • 18
  • 40
  • Why not just register both receivers (your custom receiver and the Google provided one)? Creating a new instance of a `BroadcastReceiver` is not something you should be doing. – ianhanniballake May 25 '15 at 01:05
  • 1
    All I have done is followed google on this: https://developers.google.com/analytics/solutions/testing-play-campaigns (scroll down below, there is an example). – pixelscreen May 25 '15 at 07:52
  • 2
    And moreover "There can be only one BroadcastReceiver for an action." Isn't it? @ianhanniballake – pixelscreen May 25 '15 at 08:45
  • 1
    Did you manage to solve the problem? I encounter it as well – Derekyy Jun 10 '15 at 14:57
  • 1
    seems [this solution](http://stackoverflow.com/a/30271686/2369266) works – Nicholas Ng Jul 30 '15 at 06:17
  • I get the same error message. I have been trying for several months to get this fixed but with no luck. I have read the instructions multiple times.... – Kasper Finne Nielsen Nov 13 '15 at 07:23

6 Answers6

14

I guess you didn't implemented AnalyticsService and AnalyticsReceiver? This is what I did to make it work

    <!-- Google Analytics --> 
    <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
              android:enabled="true"
              android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.CampaignTrackingService" />
    <receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
              android:enabled="true">
        <intent-filter>
            <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
        </intent-filter>
    </receiver>
    <service android:name="com.google.android.gms.analytics.AnalyticsService"
             android:enabled="true"
             android:exported="false"/>
Nicholas Ng
  • 1,428
  • 18
  • 23
8

I was confused by all the answers. But found out what it was by debugging and logging.

Basically: This warning is done on startup of google analytics. It just warns you that you didn't register CampaignTrackingReceiver in your manifest. But thats fine! Since you have your own tracking receiver. Just test your receiver by doing something like this, while debugging your app:

echo 'am broadcast \
-a com.android.vending.INSTALL_REFERRER \
-n "com.my.app/com.my.app.CustomInstallTrackerReceiver" \
--es "referrer" \
  "utm_source=promo_mail&utm_medium=emaeil&utm_term=test_term&utm_content=content&utm_campaign=derp"; \
exit' | adb shell

To check wether its really working, you can check the logs of google analytics:

adb shell setprop log.tag.GAv4 DEBUG
adb logcat -s GAv4

What I saw is the following:

12-07 11:32:54.678  6993  7011 W GAv4    : CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http : // goo.gl/8Rd3yj for instructions.
12-07 11:33:14.048  6748  6827 D GAv4    : Received installation campaign: content=content, keyword=test_term, medium=emaeil, name=derp, source=promo_mail
12-07 11:33:14.048  6748  6827 D GAv4    : Sending installation campaign to: UA-SECRET, content=content, keyword=test_term, medium=emaeil, name=derp, source=promo_mail
12-07 11:33:14.068  6748  6827 D GAv4    : Hit delivery requested: ht=1481106771894, _s=3, _v=ma9.4.52, adid=xxx, aid=com.my.app, an=Tiqets, ate=1, av=1.6.61.g785cc1e, cc=content, cid=xxx, ck=test_term, cm=emaeil, cn=derp, cs=promo_mail, ni=1, sr=1440x2560, t=data, tid=UA-SECRET, ul=nl-nl, v=1
12-07 11:33:14.098  6748  6827 D GAv4    : Hit sent to the device AnalyticsService for delivery

While it still complains. It does still track it.

TjerkW
  • 2,086
  • 21
  • 26
  • I tested the same way. It is showing "Received..." in logs but it is not showing "Sending..." part. So I can't see the data on my google analytics dashboard also. Can you please help? – Rahul Bansal Jul 18 '18 at 11:13
2

You can ignore the warning and don't need to add AnalyticsReceiver and AnalyticsService if you only target play-service enabled devices. Check https://developers.google.com/analytics/devguides/collection/android/v4/dispatch#manual for details.

Sam Lu
  • 3,448
  • 1
  • 27
  • 39
1

As long as we add

implementation 'com.google.android.gms:play-services-analytics:15.0.1

and retrieve the analytics instance to set a tracker like:

analytics = GoogleAnalytics.getInstance(this);
Tracker t = analytics.newTracker("UA-AnalyticsContainerID");

we only need to set the CampaignTrackingReceiver in the manifest:

<receiver
    android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
    android:enabled="true"
    android:permission="android.permission.INSTALL_PACKAGES">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

The CampaignTrackingService is deprecated and should not be used. Finally, you can try to test your option to send a broadcast message from adb like it is suggested in the android developer doc - if you see a hit event in the logs, it should be also visible in the analytics web after some minutes.

mathew11
  • 3,382
  • 3
  • 25
  • 32
0

This is because you are using a custom campaign tracking receiver as shown in your manifest file. however, you did redirected it to the CampaignTrackingReceiver by calling

new CampaignTrackingReceiver().onReceive(context, intent);

on your onReceive.

You might also need to send() the campaign data

mTracker.send(new HitBuilders.ScreenViewBuilder() .setCampaignParamsFromUrl(campaignData) .build() );

JoM
  • 545
  • 4
  • 11
0
Follow this tutorial for complete setup and understanding of Google Campaign tracking -

 to set up install referrer first you need to add Google Services to your android app. Go to your build.gradle(Project level) and add -

google-services plugin to your build.gradle file:

dependencies {
    classpath 'com.google.gms:google-services:4.3.3'
    // ...
}

And then add Google Analytics dependency to your app level build.gradle file.

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.google.android.gms:play-services-analytics:11.8.0'
}
apply plugin: 'com.google.gms.google-services'

 After adding dependencies we need to set up our AndroidManifest.xml. See below for tested code of AndroidManifest.xml.

<application>
 <service android:name="com.google.android.gms.analytics.CampaignTrackingService"
            android:permission="android.permission.WAKE_LOCK"
            android:enabled="true"
            android:exported="true">
        </service>
        <receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.INSTALL_PACKAGES">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>
        <receiver android:name=".UtmReceiver"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.INSTALL_PACKAGES">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>
        <receiver android:name="com.google.android.gms.analytics.AnalyticsReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
            </intent-filter>
        </receiver>
        <service android:name="com.google.android.gms.analytics.AnalyticsService"
            android:enabled="true"
            android:exported="false"/>
</application>

for detailed information you can follow this link-

http://www.digitstory.com/install-referrer-android-campaign-track/
s.j
  • 621
  • 6
  • 16