I am building an Android app that uses Google Analytics to record various Events and Screens throughout the app. The Engagement Flow dashboard is quite striking but I'd like to export the data and play with it on my own. How can I write my app so that I can extract the data that is used in the Engagement Flow dashboard using the Google Core Reporting API?
Currently, I am using sendEvent and sendView to track Events and Screens respectively in the Engagement Flow. I'm guessing my approach is working because the report works correctly in the Google Analytics UI, but I can't get the data out using the Core Reporting API for Android. I am fairly confident this is doable because I've been able to access the data using the query explorer for our website with the ga:previousPagePath and ga:pagePath dimensions (see screenshot below), but the same thing does not work for the Android SDK. I can get some data out using an undocumented ga:screenName dimension, but the corresponding ga:previousScreenName (and any permutation thereof) does not exist. Thoughts?
For what its worth, others have had similar questions in case its useful:
How to get “Visitors Flow” data from Google Analytics GAPI API?
Get Google Analytics "Visitors Flow" data from API
According to Google-Analytics, as of now this feature is not available.
Related
I am having a tough time while analysing store listing for my app with third party referrals. When i am analysing UTM sources under Store analysis in play console I don't see any visitor/ acquisition towards most of my UTM sources except few like "Firebase", "Google", "Other", "Undefined".
There used to be data for other UTM's(Our website, our desktop app) as well in past but not anymore. I wonder what went wrong, it might be possible that these UTM's are tracked under Other category somehow.
We don't have any api call in app to send related events to firebase, are we missing something here, may be install referral api? may be some other api mentioned here https://developers.google.com/analytics/devguides/collection/android/v4/campaigns#general-campaigns, but we never had anything extra apart from setting up firebase in our project, I followed https://firebase.google.com/docs/android/setup.
Is it necessary to send data to google analytics in my case like mentioned here: https://developers.google.com/analytics/solutions/mobile-campaign-deep-link#campaign-tracking, I don't feel it is right as firebase anyways tracking 'visitors' without hitting any app code.
Any suggestion on how to debug it?
I'm just getting started with using the Google Drive REST API in an Android app. (I can't use the Google Drive API for Android because the app needs to share files, and perhaps a few other things, that GDAA doesn't support.) I'm stuck on a couple of points.
The first has to do with OAuth2.0 credentials. I went through the Android quick start example and it works fine. I set up a project on my Google developer console and generated an OAuth2.0 client ID and secret and also downloaded the JSON credentials file. However, the quick start example doesn't show how to plug any of this into the app. The only thing I found in the docs that seems relevant is GoogleClientSecrets, but I don't see anything about how to use that in an Android app. (The Java quick start example uses this, but it's not integrated with Android's account manager and doesn't seem right for an Android app.) When I run the Android version of the quick start app, no activity shows up on my developer console, which suggests to me that the app is running in some sort of anonymous mode. As I understand it, that would limit the app to a very low daily quota of transactions.
Second, I noticed that the GDAA and the REST API for JavaScript both have nice file picker APIs. I couldn't find anything similar in the Java/Android API.
So here are my specific questions:
How do I use my app's OAuth2.0 credentials from the developer console in a REST API for Android Java app? I feel like I'm just missing something obvious.
Is there a file picker API for the Google Rest API for Android?
After stepping through the library as I executed the Quickstart example (a painful process, as there is no source code), I discovered the answer. It turns out that you need to specify the client ID in the manifest. Specifically, you needs the following under the <application> tag:
<meta-data
android:name="com.google.app.id"
android:value="app ID from your API console"/>
Once this entry is in the manifest, then when the app uses the Google Drive REST API to interact with Google's servers, the transaction is correctly logged as traffic in your app's console. Without this entry, the app seemed to work in my testing, but no traffic was logged. I seem to recall (from an old Google I/O video) that such "anonymous" apps still work, but have a very low usage quota (something like 10 or 100 queries/day).
For those who are curious, I found this key in the class com.google.android.gms.common.internal.zzz, found in the play-services-basement-10.2.0 library.
Save the client_id.json file downloaded from the Google API console into into your app's src/main/res directory.
I was stuck exactly the same, but after I built my app with the file included the Google API started working.
How do I use my app's OAuth2.0 credentials from the developer console in a REST API
The pages around https://developers.google.com/android/guides/api-client give you all that you need to know. In particular, note the Java Quickstart you were using is for generic Java. The way Google Play Services on Android manage credentials and accounts is very Android-specific.
Is there a file picker API for the Google Rest API for Android?
Not that I know of, but depending on your use case, you might be able to use the GDAA picker. Ultimately, both GDAA and the Java REST API are layers above your Drive storage.
Background
Google allows to perform app-invites and also track how well they improve your app installations:
https://www.youtube.com/watch?v=UfdCNYXMC9M
The problem
I made a simple app invite, and it seems people do use it, using this code:
public static Intent getAppInviteIntent(Context context) {
return new AppInviteInvitation.IntentBuilder(title,appName).setCustomImage(imageUri).setMessage(message).setCallToActionText(download).build();
}
startActivityForResult(getAppInviteIntent(this), GOOGLE_APP_INVITES_REQUEST_CODE);
This works, but in the Analytics webpage, I can't find a way to show the statistics of the app-invite, and that's even though they say it's automatic (here). Sadly, even what I've found seem quite old and they use deprecated functions.
What I've tried
I thought that maybe it's not quite automatic (because the tutorial has some extra code for the receiver part too, here), and that we might need to add some code, as this docs say :
When the user accepts an invitation and installs the app, getInvitation(GoogleApiClient, Activity, boolean) will update the invitation state to installed and return the invitation data in an intent accessed from AppInviteInvitationResult using getInvitationIntent()
Looking at Google's sample (here), I've noticed they created 2 activities. One is the main activity, which does have a call to "getInvitation" , and another is called "DeepLinkActivity" , and handles deep links (which is probably for extra data, like coupons).
I've also found some stackOverflow questions about the tracking (like here), but all I see is that people didn't succeed tracking yet.
The questions
What is the minimal code needed in order to track the invitations and how well they work, as shown on the video? What should be configured in Analytics page itself? I don't use deep linking currently, so I don't want to use it.
It seems that Google moved the app-invites feature to "firebase" gradle repositories. Is it a must-have? What are the advantages? We currently use the previous ones ("com.google.android.gms:play-services-appinvite:..." ). The dashboard of FireBase doesn't seem to include as much UI for analytics as Google Analytics. Not to mention of app-invites.
If the answer to #1 is that I need to use "getInvitationIntent", does it have to be on the main activity of the app ? Does it have to be in an activity at all (maybe broadcastReceiver?) ?
It seems it's possible to also invite to IOS too ( as shown here and here, using "setOtherPlatformsTargetApplication"). Is this correct? How does it work? What happens when an IOS user clicks the link? What should be put into the parameter of "clientId" and where do I get it from ?
Does G+ have app-invites? If so, does it also have analytics?
Great questions. I'll do my best to answer everything. Please ask if you need clarification.
Analytics tracking requires a tracking Id that you'll need to set using setGoogleAnalyticsTrackingId(String trackingId), which I don't see in your example. This tracking Id is then handed to the downstream events that record analytics tracking events for you:
When invitations are send (both email and sms).
When the invited user accepts the invitation by clicking on the invitation link or button.
When the developer calls getInvitation()
When the developer calls convertInvitation()
So, to answer your specific questions, here goes:
Just add your tracking ID to the builder as described above, and all the tracking events will be reported. No need for a deeplink, that's optional on invites.
Yes, appinvites api is copied to firebase while retaining the original. For now they are exactly the same. Future improvements will be in firebase, so migrate when you have time.
getInvitationIntent() is called on the result returned in the callback from getInvitation(), so the callback should be within an activity. Also, since you'll only expect an invitation immediately after launch, you really only need to check in the main activity and any activity that would be launched from intent filters that trigger on the deeplink. Sounds like you don't use deeplinks, so only the main activity. Generally you should call getInvitation() from all activities that may be directly launched from an invitation, this is how you determine if your app is launched from an invitation.
Yes, invites can go cross-platform in both directions, iOS -> android, and android -> iOS. You need to define both apps in the same project in console.developers.google.com, which is necessary to associate them. If there is more than one iOS app in the project, that api call is necessary to disambiguate the iOS app that is paired with the android app. The ClientID parameter is generated in the console when you create the OAuth Client Id using the pulldown menu from credentials section.
There isn't any separate G+ invites.
Answers:
The Firebase Dynamic Links on Android documentation explains how to view the analytics data shown directly in the Firebase console. The critical step is to follow the Firebase setup instructions, most importantly:
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
The Firebase analytics integration has been streamlined from the legacy integration that required a tracking Id. Now with Firebase only setup and a call to getInvitation() are needed. No additional code or tracking ids required. Remember it takes up to 24 hours to see the results in the console. However, you can see the messages being sent immediately which is a great indication that it's working. Just enable verbose logging as described in Analytics Log Events documentation.
The Firebase and android developer documentation for appinvites are identical.
Yes, you must call getInvitation() to get analytics tracking, and do the setup as described above.
The iOS and Android equivalence apps should be in the same project. Just move them to a single project in the Firebase console. You can just remove one from it's existing project and add it to the other to make a combined project. The change should be reflected instantly.
I got a new Google Analytics ID for my Android app (a game) in development (unreleased) around a week ago.
Only today, I integrated Google Analytics SDK into my game, tested it and made it send events.
For the first time, I opened my Google Analytics portal for my game and much to my astonishment, it has recorded app "views" and "sessions" from last week even before I integrated the SDK into my game (which is still unreleased).
It has recorded 40 "new users" yesterday. It doesn't make any sense.
Is there an explanation for this?
PS: Under "top device models", it shows iPhone which is impossible since my game doesn't work on iPhone.
I did check to ensure that this is the right GA ID and there is no doubt that my game is correctly associated with the GA ID.
What you are seeing are the activities of spam "visits", where the hits don't actually visit your site but rather simply, and agnostically, target your property ID. So whether you have a web app or a native mobile app, you may be hit with these "visits". You will need to set up filters to prevent these activities from affecting your data, including a filter to only allow hits from a white listed set of valid hostnames and a filter on the campaign source. This article has some great tips on how to set those up: http://www.analyticsedge.com/2014/12/removing-referral-spam-google-analytics/
In order to separate statistics from devices with different form-factors I'd like to incorporate subdomain tracking - is there any relevant feature on Android GA SDK ?
P.S. If I'm not mistaken this feature is accessed with setDomainName method in JS API consumer.
Thanks.
Why not just utilize Advanced Segments in Google Analytics which will keep everything in the same profile, but will let you use segmentation to filter the data you want in reports?
For example, you can create a segment to filter all user agents of a certain string:
INCLUDE BROWSER MATCHING REGEXP ^(Your_custom_user_agent)$