I'm extremely new to Google Analytics on Android.
I've searched quite a bit for this, but I'm not sure I have understood it correctly, but here goes :
I want Google Analytics to track a particular variable in my app.
So for instance, a variable a has a separate value for every user of the app, is it possible for me to display the average of the value of the variable in a Google Analytics dashboard ?
As per my understanding goes, we can do this using Custom Dimensions and Metrics.
I haven't been able to find any tutorial for the same.
I'd be grateful if someone could help me with a tutorial or point me to something other than the developer pages from Google.
Thank You!
UPDATE
Firebase Analytics is now Google’s recommended solution for mobile app analytics. It’s user and event-centric and comes with unlimited app event reporting, cross-network attribution, and postbacks.
Older Answer
You may use GA Event Tracking
Check this guide and this one to check rate limits before you try this.
Events are a useful way to collect data about a user's interaction
with interactive components of your app, like button presses or the
use of a particular item in a game.
An event consists of four fields that you can use to describe a user's
interaction with your app content:
Field Name Type Required Description
Category String Yes The event category
Action String Yes The event action
Label String No The event label
Value Long No The event value
To send an event to Google Analytics, use HitBuilders.EventBuilder and send the hit, as shown in this example:
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
// Build and send an Event.
tracker.send(new HitBuilders.EventBuilder()
.setCategory("Achievement")
.setAction("Earned")
.setLabel("5 Dragons Rescued")
.setValue(1)
.build());
On GA console you can see something like this:
where event value is
and avg value is
If you want to track users with specific attributes/traits/metadata then custom dimensions can be used to send this type of data to Google Analytics.
See Set up or edit custom dimensions (Help Center) and then update the custom dimension value as follows:
// Get tracker.
Tracker t = ((AnalyticsSampleApp) getActivity().getApplication()).getTracker(
TrackerName.APP_TRACKER);
t.setScreenName("Home Screen");
// Send the custom dimension value with a screen view.
// Note that the value only needs to be sent once.
t.send(new HitBuilders.ScreenViewBuilder()
.setCustomMetric(1, 5)
.build()
);
It is possible to send additional data to Google Analytics, using either Custom Dimensions or Custom Metrics.
Custom Dimensions are used for labels and identifiers that you will later use to separate your data. For example, you might have a Custom Dimension that tracks log-in status. This would allow you to break down your reports and compare logged-in traffic to not logged-in. These can contain text; while AB testing your site you might set up a custom dimension with the options 'alpha' and 'beta'. They can also contain numeric values, such as the time '08:15', or a unique identifier that you've generated (although you should be careful to follow Google's advice here, lest you include PII and rick account deletion https://developers.google.com/analytics/solutions/crm-integration#user_id).
Custom Metrics are used for numeric variables such as engagement time, or shopping cart value. They are a lot like custom dimensions, but are intended to be compared across dimensions. For example, you could compare the shopping basket value of your Organic users to those who come in via a paid link.
If you wanted to calculate an average, you would also require a calculated metric. This takes two metrics you already have, and produces a third. For example, if you site was all about instant engagement, and you wanted to track the time before the first click event on each page, you could set up that event click time as a custom metric. But this would only tell you what the total is; surely more customers are a good thing, but they make that total go up! So you set up a calculated metric that divides this total by the number of page views, giving you a value per page viewed.
There's a great guide by Simo Ahava about tracking Content Engagement that includes instructions for setting up Custom Metrics and Calculated Metrics.
http://www.simoahava.com/analytics/track-content-engagement-part-2/
However, I should warn you that his guide uses Google Tag Manager, which greatly simplifies the process of adding such customisation to your tags. If you don't want to take that step, you will have to code it manually, as recommended by Google's support https://support.google.com/analytics/answer/2709828?hl=en
Related
I'm currently working on a native Android app for my company and ran into some problems with Salesforce lately.
I hope I can find some help here.
What I want to achieve:
The company has a lot of Accounts in Salesforce with 3 important fields for the app: Name, Business (Workshop or Parts Dealer) and location(latitude, longitude)
I would like to show those Accounts(Workshops/Parts Dealers) as markers on a google map in my Android app based on a radius around the user's current location. So it would be more than sufficient to get the data as JSON or XML(i read about sObjects, which would be nice too)
The app will be freely available on Google Play Store and every user should be able to see all the Workshops/Parts dealers around the world.
The problem I'm facing is that I can't find a way to fetch the data inside my app without authenticating every user with a Salesforce-Login.
Which API is the best to use in this case?
It would be so awesome if anybody could help me with this problem.
What I tried so far:
- SalesforceMobileSDK: If i extend SalesForceApplication() i always end up with the Salesforce-Login Screen.
It seems that every client has to be authenticated for API-calls to work. I tried using the method peekUnauthenticatedRestClient(), but this method only works on full path URL's(e.g. "https://api.spotify.com/v1/search?q=James%20Brown&type=artist"), which isn't really practical for my Use-case.
I feel like I read nearly all docs about salesforce API, but can't quite get my head around how to solve this problem, although it seems like to be a pretty common use-case.
would a salesforce-apex method which would select all records inside a set radius around the user's location to be accessible without authentication?
Thanks for your help in advance!
Roman
Try asking on salesforce.stackexchange.com. Your question is more about licensing model than a particular programming problem. It might even be the case that you don't really need Salesforce for your project, you'd be better off on Heroku (even free tier) if the login piece is an issue...
All Salesforce APIs require some form of authentication. If you're positive you don't want to hardcode "Integration user" credentials in the app and you don't want to pay for (self-)registered user licenses in your org...
Try to read about these:
Site - piece of Visualforce running under specific "guest user", letting you view & interact with SF data without having to log in. You expose SF data to the world but that means it's your job to handle security (if any) and craft the API. You want to really display the data to human? Or just return JSON content or what...
Sites are meant to be displayin some incentive to contact you. Your product catalog / basic order form. Some map of nearby locations. Maybe a "contact us" form. There's limit on the traffic so eventually they'll explode as your app gets popular:
Customer Community - typically you need named licenses (even if they're fairly cheap) to let your customers log in to your SF. You create a Contact, click magic button - boom, this Contact now has a real matching User record with its own license. Think of it as some kind of step up from Sites - it'll still have some limits but will offer more than just raw API access and you'll have better control on what's going on.
How can I implement an interactive map using Google Maps API that prompts a user to select a route? For example, the Place Picker (https://developers.google.com/places/android-api/placepicker) is an interactive map that allows the user to search and select a location and I can get that information using onActivityResult(). I am looking to do something similar, but for a specific route from point A to B.
The easiest way I can think of for getting this information currently is to use the PlacePicker to get the user to choose origin and destination. Then I would use the Directions API to get the available routes. Then plot the available routes on a map and prompt the user to choose one. But this way seems a bit messy and I would like it if the user could just do everything in 1 interactive map that returns a specific route to the app.
Any suggestions on implementing the cleaner solution? What combination of Google Maps APIs could I use to achieve it?
This javascript-related question acheives something similar to what you are asking, but not with the Android API. Two possible ways forward would be:
Use the API in a similar way to them, with waypoints and directional
arrows.
Do what they did in a browser (for example in HTMLView) and put an
invisible View on top to get the clicks and select the route that way
(change the color of the selected route after getting the click).
The key information from the answer linked and others around the web seems to be to use Multiple DirectionsRenderer objects, possibly stacked in an Array.
I want Google Analytics to track a particular variable in my app.
So for instance, a variable 'a' has a separate value for every user of the app, is it possible for me to display the average(sum of the value of'a' held by every user/number of users) of the value of the variable in a Google Analytics dashboard ?
As per my understanding goes, we can do this using Custom Dimensions and Metrics.
Now as per my understanding , a custom metric value gets added to the current value and not updated as such. That too , I'm having trouble understanding scope of a custom metric.
I'm also struggling to find any good example and advanced info on Custom Variables / Dimensions.
However to the problem you describe I would try a simpler approach.
You can track event with its category, action, label. And also value.
Then, you'll have a category "ads", action "clicks", label "bannerA". And the value which could be any integer which will be represented as a sum of all values per total labels.
Example from Google Analytics dashboard if you set value 3 for each of those events:
bannerA: 203 hits. Value 609. (203*3=609)
I'm not totally sure of this, so anybody with deeper knowledge and experience, correct me if I'm wrong.
I am creating a java application to receive messages on pc using jsms API. Whenever a user sends a particular message to a no, it receives it and adds to the database, the phone number and the area/ region where it belongs.
The region can either be the area where the phone number is registered, or it can also be the current location of the device. Either of these information will help me.
I would be really glad if any one could any one guide me on how to proceed with finding out the region using java code.
Note: I'm not looking for the country. I'm looking for the state/ region. Preferable Indian states.
You could try out libphonenumber. It basically defines the region based on the number.
There is a JavaScript try page here you could perform some tests.
I'm trying to have more control on the number we have next to our apps for the user, How can we just send the exact number to show instead of sending notification that increment that number each time.
Basically the current behavior is :
Friend ask for something or give me a gift it increase the number
If another friend send me something its increase the number.
When I log to the game all the counter is reset.
Wanted behavior :
When I log to the game and i go see only one friend on the counter for this friend is reset.
We are currently using facebook-java-api but we will probably merge to restfb soon.
But if you know how to do it in any language it will probably help.
The old dashboard api support the set_count method that can reset to 0 or put the value you want for your apps.
See http://developers.facebook.com/docs/reference/rest/dashboard.setCount/
However the facebook-java-api don't support setCount but the newer restFB does so we need to update our apps to the new api.
EDIT: Note that you and extend the BasicClient and create a custom IFacebook Method with facebook-java-api it`s not clean but it do the trick utils we upgrade to a new facebook api.