I have integrated Google Analytics into my Android app. The app is a photo printing app which contains a set of predefined themes that users can choose. However, is it possible to retrieve the stats from Google Analytics (e.g., the top 5 themes selected by user) using some api rather than using the Google Analytics console?
What you are looking for to retrieve the information is the Core Reporting API. Because the Google Analytics API requires all requests to be authenticated and your users are not authorized to access your Google Analytics account It is probably best to set up the API call on the server side using a service account here is an example of how to set up a python application to use a service account to access the API.
But what should your query be?
analytics.data().ga().get(
ids='ga:' + profile_id,
start_date='30daysAgo',
end_date='today',
metrics='ga:totalEvents',
dimensions='ga:eventLabels').execute()
Your application will need a way to access the results of the query from your own servers. You might also want to look into using the Google Analytics Super Proxy which solves a similar problem of allowing external users to access the results of an authenticated API request.
You could create an event in Google Analytics that would effectively track this. Events have Categories, Actions, labels, and event values. So you can fairly effectively add a theme or anything you wanted as a dynamic value. Then you would be able to search and sort in Google Analytics on the event category and find which Theme was used the most
#Override
public void themeSelected(String theme) {
// May return null if a Tracker has not yet been initialized with a
// property ID.
Tracker tracker = Tracker.getInstance(this);
// that are set and sent with the hit.
tracker.send(MapBuilder
.createEvent("Theme", // Event category (required)
"Theme Selected", // Event action (required)
theme, // Event label - Can dynamically set this with the theme that was selected so you can search in Google Analytics on it.
null) // Event value
.build()
);
}
Screenshot showing sorting off of the Event Label. My labels were numbers that users entered. Notice you can see the number of times each one was entered in the TotalEvents Column which should give you the information you were looking for
Related
If I install the app when clicking the dynamic link. All of that information from dynamic should be still available when I open the app for the first time.How can I get that information? It is not working when I use this: getInitialLink() returns Promise<string|null>;
Since, you haven't mentioned - I'm assuming you are having problems with shorter urls, if that's the case try putting the longer url.
Or refer here on Simon's answer: When I use the long instead of short links, everything works perfectly fine.
On Android, you use the getInvitation() method to get data from the Dynamic Link:
AppInvite.AppInviteApi.getInvitation(mGoogleApiClient, this, false).setResultCallback
(/* ... */);
Then, in the callback, you can get the data passed in the Dynamic Links link parameter by calling the getDeepLink() method:
Firebase Documentation - Use Case
For future reference or detailed answer on Firebase Dynamic Links
Behave just like normal Links
In cases where the application doesn’t require installation (say, if it’s already installed) then clicking the Dynamic Link will automatically open the link to the desired screen.
Dynamic Links have a very simple process flow:
The user begins by clicking the Dynamic Link
If the the needs of the Dynamic Link target are satisfied (this is, the application being installed) then the user is navigated to the target location
Otherwise, if the application requires install in order to navigate
to the Dynamic Link target, the the user is taken to the point of
install for the application. Once the application has been installed,
the user is navigated to the target location of the Dynamic Link
And if that wasn’t all, we can integrate Dynamic Links with Firebase Analytics to track the interaction with any links that we generate for our applications. But if we only require simple tracking, then we can use the automatic built-in analytics from the Dynamic Links panel within the Firebase Console where we can also obtain attribution and referrer information for interacted links with no extra effort required from our side.
What makes it different from Google Analytics?
One of the first things that came to my mind when I read about Firebase Analytics was, “What about my Google Analytics setup?”. So if you already have Google Analytics in place, then why would you make the switch to Firebase Analytics? Well, here’s a couple of differences between the two:
Audiences
We can use Firebase Analytics to create Audiences — these are groups of users that we can then interact with using other Firebase service such as Firebase Notifications and / or Firebase Remote Config.
Integration with other Firebase Services
An awesome thing with Firebase Analytics is that we can integrate other Firebase services with analytics. For example, creating an Audience of users who have experienced a crash reported through Firebase Crash Reporting.
Lower Method Count
The Google Analytics dependency on Android has a total count of 18,607 methods and has a total of 4kb used for dependancies. On the other hand, Firebase Core (for Analytics) has a method count of 15,130 and only 1kb used for dependancies.
Automatic Tracking
When we add the firebase core dependency, it will automatically begin tracking a collection of user engagement events and device information for us — this is useful if you’re looking to only collect the minimal data for your app.
Unlimited Reporting
For up to 500 events, Firebase Analytics provides us with unlimited reporting straight out of the box for free!
No Singleton Initialisation
When setting up Google Analytics on Android we are required to initialize a Singleton instance. Firebase Analytics are simply available by fetching the instance directly from where we wish to track data. This isn’t much effort obviously but just makes the setup flow slightly easier.
Single Console
All of the data for every Firebase service is available for a single console. That makes it both easier and quicker for us to navigate from checking the analytic stats for our app to viewing the latest crash reports.
It looks like this is a react-native-firebase open bug for android
For fix the only thing that is required to be changed in module code:
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
return FirebaseAppInvite.getInvitation(pendingDynamicLinkData) != null;
}
to
private boolean isInvitation(PendingDynamicLinkData pendingDynamicLinkData) {
FirebaseAppInvite invite = FirebaseAppInvite.getInvitation(pendingDynamicLinkData);
if (invite != null && invite.getInvitationId() != null && !invite.getInvitationId().isEmpty()) {
return true;
}
return false;
}
Bug reference : https://github.com/invertase/react-native-firebase/issues/1273
Please Check Your Manifest file
open AndroidManifest.file => In your activity tag there is intent-filter tag put below line in that tag.
<data android:scheme="https" android:host="your.dynamic.link" />
<data android:scheme="http" android:host="your.dynamic.link" />
If already done then check this link for the full blog on the dynamic link with react native.
Link: http://blog.logicwind.com/react-native-dynamic-links-using-firebase/
I hope this will help. sorry for the typos.
As of my googled data, i got to know how to integrate GTM with the xamarin app. Based the url here.
The Tag manager is able to push the events to the GTM.
So question is, how to get the application data associated with GTM in the Google Analytics.
I get some links and videos while surfing for this, all are explaining about the GA for Web applications. Am looking the same for Xamarin Android application.
Edit:
Adding to the question, Will GTM capture all the button clicks with out pushing the data?
Will the data like 'submit button clicked' is transferred to GA via GTM?
Thanks
Suppose you have an image and want to know how many people clicked on it.
When the user clicks on the image you run this piece of code:
var dataLayer = new Dictionary <string, object> ();
dataLayer.Add ("event", "imageClick");
dataLayer.Add ("imageName", "Bart Simpson");
Android.Gms.Tagmanager.TagManagerClass.GetInstance (context).DataLayer.Push (dataLayer);
To get this data on GA through GTM you have to follow these steps on your GTM Container:
Create a new TAG
Choose Google Analytics as the product
Set the GA's Tracking ID and Track Type to Event
Set the Category to {{Platform}} (this will get Android)
Set the Action to {{Event}} (this will get imageClick)
Set the Label to a new Variable of the DataLayer type and named as imageName (this will get Bart Simpson)
Set Fire On to Any Event (this will trigger everytime an event is pushed to GTM)
Save and publish your container
Now you can see the events popping in you GA Console. You can send multiple variables in one push, but you will have to create multiple Tags with different events to see them in GA.
Edit:
No, you must push events to the DataLayer.
Only if you configure the TAG as explained above.
On GTM there is basic tracking for web that is the same as inserting the google analytics tracking code on each page of your website, but that only works for basic stuff like page views, not custom events on buttons.
Source
i have 2 different apps in the appstore, i am saving some data in a database (sql) like uid, ip, what page the user is on etc.
Is there a way to give a unique visitor an id or something like that so i can track the users activity in both apps.
And is it possible to see what buttons the user is clicking on.
I have added google analytics to the app but i only can see that there is a user on com.example.mainactivity and not the html pages that are the app.
Hope you guys understand what i mean.
You can use Google analytics to solve this problem with two different approaches. You can use the built in userId feature and it will even keep track of cross device sessions.
/**
* An example method called when a user signs in to an authentication system.
* #param User user represents a generic User object returned by an authentication system on sign in.
*/
public void onUserSignIn(User user) {
// Be careful when creating new trackers -- it is possible to create multiple trackers for the
// same tracking Id.
Tracker t = GoogleAnalytics.getInstance(context).newTracker("UA-XXXX-Y");
// You only need to set User ID on a tracker once. By setting it on the tracker, the ID will be
// sent with all subsequent hits.
t.set("&uid", user.getId());
// This hit will be sent with the User ID value and be visible in User-ID-enabled views (profiles).
t.send(new HitBuilders.EventBuilder().setCategory("UX").setAction("User Sign In").build());
}
Alternatively, you can use the Data Import feature to import external user infromation from multiple sources such as CRM data base and your SQL data base and you need to map their user representations to your own custom dimensions. You can follow the example in "Importing User Data to create AdWords Remarketing Lists" article. It shows how to use a custom dimension to represent a user id, and then upload even more custom dimensions about that user.
ga('create', 'UA-XXXX-Y', 'auto');
ga('require', 'displayfeatures');
ga('set', 'dimension1', 'NNNN'); // Where NNNN represents the CRM User Id.
ga('send', 'pageview');
Remember though Google Analytics does not support sending Personally Identifiable information, see the TOS.
I am trying to send the custom data in google analytics version 4 where the sending procedure seems to be different then previous version, I have create a custom dimention from google analytics web page then with the corresponding index I am sending the repective value as mention below,
Tracker tracker = ((Application) getApplication())
.getTracker(TrackerName.APP_TRACKER);
tracker.send(new HitBuilders.AppViewBuilder()
.setCustomDimension(1, "info1")
.build());
tracker.send(new HitBuilders.AppViewBuilder()
.setCustomDimension(2, "info2")
.build());
from the logs it seems that the data is send but not sure as I am unable to view any data in the google analytics web page.
You'll have to create a custom report and select the custom dimension, and any metrics associated with that custom dimension. For some reason Google hasn't (and who knows if they will) update the Custom Variables report.
You can define a custom report (Google Analytics > Customization (top tab)), but you need to make sure you select the right Metric or your information will not appear (e.g. ga:hits). https://support.google.com/analytics/answer/1151300?hl=en
Alternatively you can query the information through Google Analytics Query Explorer, although not choosing the correct dimension / metric will result in no data to appear (e.g. ga:dimension1 + ga:hits). http://ga-dev-tools.appspot.com/explorer/
Obviously might take a few good seconds / couple of minutes for information to be available, and important for fresh information make sure the date range includes today (yes, it happens to best of us to refresh furiously and find out Google Analytics date range was up to yesterday :-)
Developer reference (for anyone else looking for it): https://developers.google.com/analytics/devguides/collection/android/v4/customdimsmets
I am new to Google Analytics.
I want to track my application by unique user id.
I am using Google Analytics SDK for Android v3.
I have this code on onStart().I read about user id and created a new view for user tracking.
Tracker tracker = GoogleAnalytics.getInstance(this).getTracker("UA-xxx-2");
tracker.set(Fields.SCREEN_NAME, "Main Acitivty");
tracker.set("&uid", id);
tracker.send(MapBuilder.createAppView().build());
But I am not getting how can I get this uid in my Google Analytics Console,
I am trying to track user by their user_id , so I can get complete report of particular user.
I am able to get count of the total active user , screens and hit events.
But I didn't get any success on getting the same report user-wise.
I also tried to create custom dimension and metrics but those are also not reflecting on account.I have no idea Where can I check this field.
For custom variables :
easyTracker.send(MapBuilder
.createAppView()
.set(Fields.customDimension(1), "premiumUser")
.build()
);
I have searched , but I didn’t find any good tutorial on this.
Any help, suggestion , reference link would be greatly appreciated.
Thanks.
User Id is only used internally to make sure that the sessions from one user are tracked together - it just makes your stats more accurate, and enables cross device analytics.
You cannot acces the userId though:
User ID - Feature Reference
Limits
The User ID value can not be queried as a dimension in reports in either the web interface or the APIs
Also be sure not to send any user id like name or email:
User ID Policy
You will not upload any data that allows Google to personally identify an individual (such as certain names, social security numbers, email addresses, or any similar data)
You can find User ID Converage under Behaviour in the Audience section
check this image: