简体   繁体   中英

Google Analytics v4, Campaign Not Found

I am always getting "no campaign data found" error. Following is the steps that I followed. Please tell where I am wrong. I am using Android Studio.

1) I included latest google play library project.2) Added following lines in XML file

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

3) I added 2 files analytics.xml and global_tracker.xml in res/values

Analytics.xml

<?xml version="1.0" encoding="utf-8" ?>

<resources>
<!--Replace placeholder ID with your tracking ID-->
<string name="ga_trackingId">UA-******-1</string>

<!--Enable automatic activity tracking-->
<bool name="ga_autoActivityTracking">true</bool>
<string name="ga_logLevel">verbose</string>
<!--Enable automatic exception tracking-->
<bool name="ga_reportUncaughtExceptions">true</bool>

Global_tracker.xml

<?xml version="1.0" encoding="utf-8"?>

<!-- how often the dispatcher should fire -->
<integer name="ga_dispatchPeriod">30</integer>

<!-- Treat events as test events and don't send to google -->
<bool name="ga_dryRun">false</bool>

<!-- The screen names that will appear in reports -->
<string name="com.xyz.abc.def">My Activity</string>

Then I installed the app and fired following command

adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n mypackage/com.google.android.gms.analytics.CampaignTrackingReceiver --es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"

Then I saw following in logcat. Please tell where I am wrong

V/GAV4    (23030): Thread[GAThread,5,main]: connecting to Analytics service
V/GAV4    (23030): Thread[main,5,main]: service connected, binder: android.os.BinderProxy@49cf026
V/GAV4    (23030): Thread[main,5,main]: bound to service
V/GAV4    (23030): Thread[GAThread,5,main]: connect: bindService returned true for Intent { act=com.google.android.gms.analytics.service.START cmp=com.google.android.gms/.analytics.service.AnalyticsService (has extras) }
V/GAV4    (23030): Thread[main,5,main]: Connected to service
I/GAV4    (23030): Thread[GAThread,5,main]: No campaign data found.

I think you should take a look on Troubleshooting chapter in Testing tracking campaign doc .

I think the most important is changing Google Analytics' log level to verbose, because without that you can't be 100% sure, that logs in logcat came from your app.

GoogleAnalytics.getInstance(this).getLogger().setLogLevel(Logger.LogLevel.VERBOSE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM