Testing a Google Analytics V4 Campaign Testing Doesn't Work

I started measuring campaigns using Google Analytics V4, linking to https://developers.google.com/analytics/devguides/collection/android/v4/ . Before you test Campign Measurement, as described in https://developers.google.com/analytics/solutions/testing-play-campaigns . Every time my magazines show "No campaign data"

I imported Google Play services (Rev: 18) into my workspace and transferred it to my project

Added below lines in my manifest file

<uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <meta-data android:name="com.google.android.gms.analytics.globalConfigResource" android:resource="@xml/global_tracker" /> 

as well as below code

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

later created global_tracker.xml file under res-> xml. Below is my xml file

  <?xml version="1.0" encoding="utf-8" ?> <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes" > <integer name="ga_sessionTimeout">300</integer> <!-- Enable automatic Activity measurement --> <bool name="ga_autoActivityTracking">true</bool> <bool name="ga_debug">true</bool> <string name="ga_logLevel">verbose</string> <string name="ga_dryrun">true</string> <!-- The screen names that will appear in reports --> <!-- The following value should be replaced with correct property id. --> <string name="ga_trackingId">UA-xxxxxxx-1</string> </resources> 

replaced the tracking id with my tracking id

during testing campaign measurement, I first installed the application on my device (Moto G (4.4.2)) via adb install. Make sure that the application is not working and translates the intent, as indicated in the link above. I got a success log when an intent was broadcast.

Intention

 E:\xxxxxxx\adt-bundle-windows-x86_64-20140321\sdk\platform-tools >adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n <My Package name>/com.google.android.gms.analytics.CampaignTrackingReceiver --es "referrer" "utm_source=testsource" 

Answer:

 Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=<My Package name> >/com.google.android.gms.analytics.CampaignTrackingReceiver (has extras) } Broadcast completed: result=0 

When I opened my application, I always got " I / GAV2 (7342): Thread [GAThread, 5, main]: no data in the campaign. " In my logs.

Can someone tell me why I am not receiving campaign data? where am i wrong

Also, why does it show β€œGAV2” in the logs when I use GAV4

GA Magazines:

 07-09 12:59:26.542: W/GAV2(20502): Thread[main,5,main]: Need to call initialize() and be in fallback mode to start dispatch. 07-09 12:59:31.568: I/GAV2(20502): Thread[GAThread,5,main]: No campaign data found. 

Note. . This is the first time I've been working with Google Analytics. Since I want to check whether I receive campaign data or not, I have not implemented any trackers in GA

Edit: When I manually launch a broadcast intent when I click a button in my application. I can see the Campaign Found log when I restarted the application. But the same thing does not happen when triggered using the adb shell command, as described above. I doubt that I do not intend to get to my device. Is there any way to know if an intention is received or not?

Please, help

+7
android android-intent android-service google-analytics google-analytics-v4
source share
6 answers

1> ok for starters you mix two things. this link is for google analytics-v4 https://developers.google.com/analytics/devguides/collection/android/v4/ and this link is https://developers.google.com/analytics/solutions/testing-play-campaigns not for v4 (the page is too old, there was no GAV4 when this page was published.

2> Check the version of the physical device (Google Play) and upgrade it to 5.0, if not already done.

3> You do not need the boiler plate code mentioned below. I think this is for GAV3, not GAV4

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

for clarity of code check this link. Campaign data not found. Using Google Analytics v4

4> In particular, for GAV4 (with my own experience), it’s normal to see the error "No campaign data". try running the code in verbose mode and you will see that GAV4 is establishing connections with its host.

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

5> Do not enable dry_run, you will not see the data in Google Analytics. This is disabled by default.

6> finally, inside Google Analytics, see the "Live" section for live performances.

hope this helps.

+6
source share

I had the same problem with an additional ClassNotFound error sometimes.

First I suggest seeing Nishant's answer, and here are a few more things to check if they resolve your problem:

1) If you have more than one BroadcastReceiver:

1.1) Make sure you do not! Hold only one and add an intent filter to this:

  <service android:name="com.google.android.gms.analytics.CampaignTrackingService"/> <receiver android:name="com.example.MyScheduleReceiver" android:exported="true"> <intent-filter > <action android:name="android.intent.action.ACTION_USER_PRESENT" /> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE"/> <action android:name="android.intent.action.ACTION_SCREEN_OFF" /> <action android:name="android.intent.action.ACTION_SCREEN_ON" /> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="com.android.vending.INSTALL_REFERRER" /> </intent-filter> </receiver> 

1.2) Then at the end of the BroadcastReceiver, send the intention to the correct recipient:

@Override
public void onReceive (context context, intent intention) {

  //Do your code for the other intents new CampaignTrackingReceiver().onReceive(context, intent); 

}

2) Calling the correct version of Google Analytics is also a problem when reading a Google tutorial, as some links constantly redirect you to older versions of the library. If you are using v4, then:

2.1) Remember to enable libGoogleAnalyticsV2.jar

2.2) Double check that you write com.google.android.gms.analytics .CampaignTrackingService all the time and on all imports.

3) When using ADB, to check if its operation checks the previous points. In the above example, the correct line to call ADB would be:

 adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.example/com.example.MyScheduleReceiver --es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign" 
+1
source share

To do this, create a CustomReceiver and submit the google CampaignTrackingReceiver intent to GoogleAnalyticsv4.

With this you get CampaignFound in the logs

 public class CustomCampaignTrackingReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { new CampaignTrackingReceiver().onReceive(context, intent); } } 
0
source share

Install the apk file on your device.

 adb install filename.apk 

Type the following adb command:

 ..\sdk\platform-tools>adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n your.package.name/com.google.android.gms.analytics.CampaignTrackingReceiver --es "referrer" "utm_source=testSource" 

Please note that the command specified in this link has a V3 receiver.

Check logcat. The campaign message should be there. Make sure the application is not running when sending the referrer. The application should only start after its completion.

0
source share

May be useful to someone ... I was getting GAv4: Discarding hit. Missing tracking id parameter GAv4: Discarding hit. Missing tracking id parameter , because instead:

 GoogleAnalytics.getInstance(context).newTracker(R.xml.app_tracker); 

I added

 GoogleAnalytics.getInstance(context).newTracker(R.string.ga_trackingId); 

Pay attention to the difference xml.app_tracker vs string.ga_trackingId !

Use the xml.app_tracker configuration file!

0
source share

As I checked in my last implementation. Perhaps the log may be broken. I got "No campaign data" in the logs, but I see real data in the web console.

I am using v4 and my manifest is as follows:

 <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> <service android:name="com.google.android.gms.analytics.CampaignTrackingService" /> 

Good luck.

0
source share

All Articles