I am trying to setUp google analytics campaign measurements measurements .
here is what i did :
1.
i've declared the receiver in the manifest file:
<!-- Enable Google Play Store Campaign reports -->
<receiver android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true"
android:permission="android.permission.INSTALL_PACKAGES">
<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" />
I install the app on my device using this command:
./adb install debug.apk
then i run this using my terminal , to broadcast the intent :
./adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n "com.mypackgename/com.google.android.gms.analytics.CampaignTrackingReceiver" --es referrer "utm_source=test2Source&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"
which return this :
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=com.mypackagename/com.google.android.gms.analytics.CampaignTrackingReceiver (has extras) }
Broadcast completed: result=0
but i got this in my log:
Thread[GAThread,5,main]: No campaign data found.
what should i do to make it work, i'v try a lot of things but without luck.
You'll have to URL encode the arguments in the referrer string.
Please try the following:
./adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n "com.mypackgename/com.google.android.gms.analytics.CampaignTrackingReceiver" --es referrer "utm_source%3Dtest2Source%26utm_medium%3DtestMedium%26utm_term%3DtestTerm%26utm_content%3DtestContent%26utm_campaign%3DtestCampaign"
For more information check out: How to test android referral tracking?
Related
Broadcast which should be sent to the application just after app is installed on TV is not received.
I declared BR in Manifest.xml:
<receiver
android:name=".RunOnInstallReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.media.tv.action.INITIALIZE_PROGRAMS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
I declared also:
<uses-feature
android:name="android.software.leanback"
android:required="true" />
RunOnInstallReceiver class is very simple:
public class RunOnInstallReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Log.v("RAMPS", "Broadcast received");
}
}
I tried with nVidia Shield and Mi Box 3 - no success. Anyone had similar problem?
Are you side loading the application? INITIALIZE_PROGRAMS is only sent when the application is installed via the store.
When side loading (installing from adb or android studio), you can trigger the intent with:
adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n com.your.app.package/.YourReceiver
Answer is from bullet #5 in Android developer guide for creating a channel on the home screen: https://developer.android.com/training/tv/discovery/recommendations-channel#creating_a_channel
In my case, if you use product flavor you should trigger by:
adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n X/Y
X is your applicationID.
Y is the link of your broadcast received file in your project.
Example: You build your application with Build variants staging and trigger is:
adb shell am broadcast -a android.media.tv.action.INITIALIZE_PROGRAMS -n com.google.android.staging/com.google.android.tvhomescreenchannels.RunOnInstallReceiver
Here is ApplicationId:
Here is path RunOnInstallReceiver:
I'm trying to have install referrer on my android app, but failed for something.
I need to receive variables when someone download/install my app form appstore. So I install a cordova plugin, android-referrer-plugin, into my app. And then try it:
adb shell
and then
am broadcast -a com.android.vending.INSTALL_REFERRER \
-n com.mypackage.app/com.eightz.mobile.cordova.plugin.android.referrer.Receiver \
--es "referrer" "This is my referrer"
And then I've got a response like this:
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER cmp=com.mypackage.app/com.eightz.mobile.cordova.plugin.android.referrer.Receiver (has extras) }
And that's it.. I don't see
Broadcast completed: result=0
I'm not sure if it's long loading for something or what, but I never see this line, and I cannot further on.
I check if I can get the variable, but I just got empty variable. No error though..
Could someone point my mistake here?
Did you regsiter broadcast receiver in manifest. Did you set intent filter to that receiver in manifest too.
<receiver android:name="com.mobileapptracker.Tracker" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Please find the below code for more information.
<receiver
android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
android:exported="true"
android:enabled="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"/>
This is what I have done for implementing Campaign Measurement - Android SDK v4.
In order to check is it working or not, when I try to run this on terminal:
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n
"com.example.android/com.google.android.gms.analytics.CampaignTrackingReceiver"
--es referrer "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"
it successfully cast an intent
Broadcasting: Intent { act=com.android.vending.INSTALL_REFERRER
cmp=com.example.android/com.google.android.gms.analytics.CampaignTrackingReceiver
(has extras) } Broadcast completed: result=0
and when I run my application I get the log as follows:
CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.
I had tried many example but not got the sufficient result. Anyone if knows the whole working then please provide me a link or if anybody knows the exact steps plz list them.
Thanxx in advance
I'm not getting install referrer received on application installed from the play store. Below is my Androidmanifest.xml shows receiver which is inside <application> tag too.
<receiver
android:name="com.usplnew.getreferrer.CustomReceiver"
android:exported="true" >
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
And below is code for Receiver
public class CustomReceiver extends BroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
System.out.println("sgn RECEIVED");
Log.d("YES", "IT WORKS!!");
Toast.makeText(context, "Received Intall Referrer", Toast.LENGTH_SHORT)
.show();
}
}
Its working well with below command on emulator and device too
adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n com.uspl.getrefferer/com.uspl.getrefferer.CustomReceiver --es "referrer" "https://play.google.com/store/apps/details?id=com.NextGen.Water.Run&referrer=IWantThisReferrer"
I also put the same below code into the app into the production on Google Play. But INSTALL REFERRER is not received when the application is installed.
I would highly appreciate if someone guide where I'm wrong.
Thanks in Advance!
Have you checked your implementation of your own class of BroadcastReceiver with this documentation - https://developers.google.com/analytics/devguides/collection/android/v1/devguide#campaigns
?
I'm trying to simulate as if the device is receiving a GCM push message by using adb and the command line. I've tried this command to broadcast a GCM intent:
adb shell am broadcast -c com.myapp -a com.google.android.c2dm.intent.RECEIVE -e data "SomeData"
This triggers a "Permission denial" log line though:
09-19 12:23:34.820 725-787/? W/BroadcastQueue﹕ Permission Denial: broadcasting Intent { act=com.google.android.c2dm.intent.RECEIVE cat=[com.myapp] flg=0x10 (has extras) } from null (pid=21244, uid=2000) requires com.google.android.c2dm.permission.SEND due to receiver com.myapp/com.google.android.gcm.GCMBroadcastReceiver
Relevant parts of my manifest:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.myapp" />
</intent-filter>
</receiver>
</application>
Any ideas?
Edit / clarification: Push / GCM receive works in production. I'm looking for an easier way to test changes.
You need to remove the permission property in your receiver's definition like this:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.myapp" />
</intent-filter>
</receiver>
</application>
Better than temporarily editing AndroidManifest.xml to remove the permission check, and remembering to restore it later, you can automatically disable the permission check in debug builds.
To do this, set the attribute via a Manifest Merger placeholder:
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="${gcmPermissionRequired}">
then set the placeholder in build.gradle:
buildTypes {
debug {
...
manifestPlaceholders = [gcmPermissionRequired: ""] // "" => let the GCM BroadcastReceiver accept Intents from 'adb shell am broadcast'
}
release {
...
manifestPlaceholders = [gcmPermissionRequired: "com.google.android.c2dm.permission.SEND"]
}
}
(Note: Previously I used debug & release string resources. It turns out that the Play store rejects the app if it defines an intent filter permission using a string resource.)
I suggest using command-line curl, as sending GCM pushes is as easy as calling some REST API. See sample shell script below:
#!/bin/bash
REGISTRATION_ID=YOUR_GCM_REGISTRATION_ID
SERVER_KEY=YOUR_SERVER_KEY_FROM_GOOGLE_API_CONSOLE
curl --header "Authorization: key=$SERVER_KEY" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{ \"data\" : {\"foo\": \"bar\"}, \"registration_ids\":[\"$REGISTRATION_ID\"] }"
Install adb first.
sudo apt-get install adb
Remove the SEND permission from manifest.xml.
android:permission="com.google.android.c2dm.permission.SEND" >
Command to push notifications from shell
adb shell am broadcast -c com.myapp -a
com.google.android.c2dm.intent.RECEIVE -e data "SomeData"
Change the package name (com.myapp) and "SomeData" as you want.