Hi I'm Android developer, and I met a challenge about using Google Analytics Campaign using SDK v4.x.
I have refered to the following URL
https://developers.google.com/analytics/solutions/testing-play-campaigns
And I finished the step of 'Broadcasting an INSTALL_REFERRER Intent'
Because I could see this message successfully.
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER
cmp=com.example.analyticsecommtest/com.google.analytics.tracking.android.AnalyticsReceiver
(has extras) }
Broadcast completed: result=0*
But I found this log :
Thread[GAThread,5,main]: No campaign data found.
The reference URL said, the log means that my Google Play Campaign Measurement implementation is not working correctly. Thus I tried to fix the work as checking out troubleshooting section.
there are several reasons.
The INSTALL_REFERRER intent was not broadcast
-> I finished it as I told
The Google Analytics Receiver did not receive the intent
-> I implemented CampaignTracking correctly, I think.
and only CampaignTrackingReceiver uses INSTALL_REFERRER.
Now, What can I do to implement CampaignTracking successfully?
and do I need to implement Receiver.class that extends BroadcastReceiver? (even I use SDK v4.x)
one more question, if I send setCampaignParamsFromUrl on my application code, what happen is going on?**
Here is AndroidManifast xml code.
<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"
android:enabled="true" />
<service android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>
<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>
please answer anyone who has used Google Analytics Campaign successfully.
Thank you.
Related
I have a Install referrer receiver in my manifest.
<receiver
android:name="xx.yy.zz.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
And I get the referrer in the broadcast receiver as:
String referrer = intent.getStringExtra("referrer");
My doubt is would the receiver also listen to broadcasts of other apps which are installed with a referrer.
I want to listen to broadcasts for my app only.
If this problem exists, what would be the solution for it?
<receiver
android:name="xx.yy.zz.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
**<data android:scheme="package" />**
</intent-filter>
</receiver>
add your package in the receiver and while receive the broadcast in the OnReceive method check for your package
this will solve your problem
I recently did a code scan on my Android source code using HPFortify service. They reported security vulnerability regarding google analytics receiver. They suggested to use the broadcaster permission to reduce the attack vector. This way you are restricting broadcaster, otherwise any malicious application can send the intent and broadcast receiver will process it.
Here is my AndroidManifest file.
<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"/>
I am trying to figure out the broadcaster permission for AnalyticsReceiver. According to HpFortify the broadcast receiver should look like similar to this:
<receiver
android:name="com.google.android.gms.analytics.AnalyticsReceiver"
android:permission="SOME-GOOGLE-ANALYTICS-PERMISSION"
android:enabled="true">
<intent-filter>
<action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH"/>
</intent-filter>
</receiver>
Edit 1:
I am also looking for the source code to figure out the right permission. But I couldn't find the google analytics source code.
I am tracking my installs with two methods like you can see here in my manifest:
<receiver
android:name="com.google.android.gms.tagmanager.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<receiver
android:name=".tracking.ReferralReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
The second receiver generates a lint warning the first not. Does that mean that Google knows that for their InstallReferrerReceiver and know that it is safe to let it exported?
PS: I know I can use tools:ignore="ExportedReceiver".
The INSTALL_REFERRER intent is broadcasted when an app is installed from the Google Play Store.
android:exported="true" means that the receiver is allowed to receive broadcast intents from other applications. You do want this, or you will not be able to receive the event which is sent by another app (the system or the Play Store app, I'm not sure).
However, if you check the documentation for android:exported, its default value is true if it has at least one <intent-filter>, otherwise it is false.
So to sum up, you need android:exported="true" to catch the event. But omitting this property would be also OK, since the default value is true for your receivers (but it's safer to have it).
About the Lint warning: It recognizes the name, and that's why it knows that the first version is safe.
I am trying to implement google analytics service to android app using the following documentation provided in sdk:
https://developers.google.com/analytics/devguides/collection/android/v4/
I am unable to see any information in the analytics admin site.
While the app is running, I am seeing following debug message
"AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See https://developers.google.com/analytics/devguides/collection/android/v4/ for instructions."
Can you please suggest me how to register this service?
I am not sure if acting on this warning will solve the issue you're having (i.e. not seeing any information in the Analytics admin site).
Anyway, here is what you should add to AndroidManifest.xml inside the application tag if you want to get rid of this warning:
<!-- Optionally, register AnalyticsReceiver and AnalyticsService to support background
dispatching on non-Google Play devices -->
<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"/>
<!-- Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
installation campaign reporting -->
<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" />
You don't have to add all of this, just add what you need. In your case, you apparently just need to add the AnalyticsService service.
Source: https://developer.android.com/reference/com/google/android/gms/analytics/GoogleAnalytics.html
add this on manifest
<service android:name="com.google.android.gms.analytics.AnalyticsService"
android:enabled="true"
android:exported="false"/>
Karim explained it well, but it won't work until you give the Wake lock permission in the manifest.
<uses-permission android:name="android.permission.WAKE_LOCK" />
Google v4 dispatch reference.
I had quite similar problem - message about AnalyticsService looks like your device doesn't have Google Services, but it wasn't true for me. However, I've realized that I couldn't be sure that this log'd been invoked from my app - log looked like that: 10173-10192/? V/GAV4, so package name was hidden.
To see logs from Google Analytics, you should change log level to verbose:
GoogleAnalytics.getInstance(this).getLogger().setLogLevel(Logger.LogLevel.VERBOSE);
It will help you to analyze, what is a cause of your problems.
According with this:
Note that Google may periodically refresh the registration ID, so you should design your >Android application with the understanding that the >com.google.android.c2dm.intent.REGISTRATION intent may be called multiple times.
I'm using the new GCM ( Google Play Services ), so i thinked to use a Broadcast Receiver for this intent:
<receiver
android:name="com.example.gcmclient.RegistrationHandler"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
</intent-filter>
</receiver>
I would use this Broadcast Receiver to be able to detect that Registration_ID is changed and send it to my server. Can i do this or i am on a wrong way?