Google Analytics for Android SDK, setting multiple custom dimensions - android

Inside Google analytics admin section I created 4 custom dimension. 1st dimension scope is "user", 2nd, 3rd and 4th dimension's scope is "hit".
I set parameters inside my onCreate function and send them in onStart command of my Activity. But when I check custom reports, I see that 1st dimension is set correctly. But no data for other 3 dimensions. I tried different days and waited but no change. I can see 1st dimension's data successfully. How can I set these custom dimensions, what do I miss ?
#Override
public void onCreate(Bundle savedInstanceState) {
MyUtil.initializeGAtracker(mContext);
MyUtil.getGaTracker().set(Fields.customDimension(1), "aaa");
MyUtil.getGaTracker().set(Fields.customDimension(2), "bbb");
MyUtil.getGaTracker().set(Fields.customDimension(3), "ccc");
MyUtil.getGaTracker().set(Fields.customDimension(4), "ddd");
MyUtil.getGaTracker().set(Fields.SCREEN_NAME, "myscreen");
}
#Override
public void onStart() {
super.onStart();
MyUtil.getGaTracker().send(MapBuilder.createAppView().build());
}
I also tried this. But it didn't help:
MyUtil.getGaTracker().send(MapBuilder
.createAppView()
.set(Fields.customDimension(2), "bbb")
.set(Fields.customDimension(3), "ccc")
.set(Fields.customDimension(4), "ddd")
.build()
);
Is there a detailed resource for setting multiple custom dimensions ?
I only found this:
https://developers.google.com/analytics/devguides/collection/android/v3/customdimsmets
Edit: Documentation is not adequate, also custom dimensions documentation has syntax error.

The code that you provided should work correctly.
Can you provide more details on MyUtil class?
Do you see any errors in debug mode? The SDK should output a bunch of errors if there is something wrong.
The SDK also prints out the hits that it is sending over wire. Can you copy and paste one of such hits here?
Also, your code snippets do not show you setting the tracking id. Can you check that you have set the ID? You can set it in the xml config or in the SDK APIs.

Related

play-games-plugin-for-unity - show specific Leaderboard

I'm trying to integrate the google play Leaderboard with help of the play-games-plugin-for-unity plugin into my game.
It works fine, committing to Leaderboard an all, only one thing is not working. When I call the Leaderboard
//LEADERBOARD
if (GUI.Button(leaderboardButton, "Leaderboard"))
{
((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(Constants.LEADERBOARDID);
// Social.ShowLeaderboardUI();
}
it opens the window where I see all leaderboards. But I'm giving a specific id. This would be the behaviour I expect from the line Social.ShowLeaderboardUI(); which is commented out. The overload with a given Id (hid behind Constants.LEADERBOARDID) should start the specific Leaderboard UI according to the doc. Someone knows if this is an issue (haven't seen any report on GitHub) and how to solve it? It isn't that that big of an issue, but one click is better than two.
I tried something interesting. I changed the Id to some wrong value. Still the same behavior (opening the window with all leaderboards). Of course committing the score doesn't work anymore.
Okay, i found the error in the sourcecode of the Plugin, fixed it and resolved the problem. So here I present the fix if someone needs it. It's in the LeaderboardManager class.
This is how ShowUI is called:
internal void ShowUI(string leaderboardId, Action callback) {
Misc.CheckNotNull(callback);
C.LeaderboardManager_ShowAllUI(mServices.AsHandle(), Callbacks.InternalShowUICallback,
Callbacks.ToIntPtr(callback));
}
This should be the correct version
internal void ShowUI(string leaderboardId, Action callback) {
Misc.CheckNotNull(callback);
C.LeaderboardManager_ShowUI(mServices.AsHandle(),leaderboardId, Callbacks.InternalShowUICallback,
Callbacks.ToIntPtr(callback));
}
}
See the difference? C.LeaderboardManager_ShowAllUI instead of C.LeaderboardManager_ShowUI is called.

BubblePopupHelper filling Android Debug Log

So I noticed when I was debugging that there seems to be a tag that's repeating through my app entitled "BubblePopupHelper" with text: "isShowingBubblePopup : false"
Screenshot of the log
To my knowledge, I'm not using or causing it. Does anyone have an idea of what's going on? The application is the one I'm writing.
Upon further inspection, I did notice that every time I'm updating text (via a TextView) it displays onscreen. If there's a better way of doing so, please let me know.
Thanks!
The message seems to be logged by some SDK libraries whenever setText is called in a TextView. I get it in Android Studio developing with min API 14.
One interim solution till Google removes it would be using the filtering feature of Android Studio by writing a RegEx that only includes your log messages. For example if I have all my tags start with 'Braim' then 'Braim.*' can be used
If you want to filter this annoying logs away you can use the following regex:
by Log Tag: (?!^BubblePopupHelper)(^.*$)
Have you added "OnGlobalLayoutListener"?
I've encountered same problem and finally I found that getViewTreeObserver().addOnGlobalLayoutListener caused the problem.
Here is my solution:
textView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
...
textCategory.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});

Google Tag Manager Not Showing Values

I just started working on Google Tag Manager. I got it worked. But I faced one issue. That is, each time I edit or add some new macros, I need to create new version and publish it. Unless I am not downloading the new version and saving inside assets/tagmanager and also unless I refer with the new version name of the downloaded file, I am not able to see my updates.
Is it so? If so, I didn't understand why this is useful. Is anything done by me went wrong?
I got it worked.The issue was when we keep the json or binary inside assets folder, then on openContainer() call, Google Tag Manager will check for the saved file first. Then only it will goto the network and search. This caused issue to me. So I removed the file kept inside assets/tagmanager folder.
Also I called container.refresh() before we set value inside the singleton class.
Sample code:
ContainerOpener.openContainer(tagManager, CONTAINER_ID, OpenType.PREFER_NON_DEFAULT,
TIMEOUT_FOR_CONTAINER_OPEN_MILLISECONDS, new ContainerOpener.Notifier() {
#Override
public void containerAvailable(Container container) {
container.refresh();
// Save container for use by any other activities in the app.
WPContainerHolder.setContainer(container);
//perform your other functionalities
}
});

How do I implement facebook login into an app I just started developing?

I'm all very new to developing android applications and have only a base amount of knowledge when it comes to developing such.
I'm trying to start off with making some implementation of the Facebook login features, but the guide I found on Facebook makes everything way worse than it should be.
I'm hoping someone could give me a thorough walk-through from start to end on how to make a facebook login start page and do proper authentication with ones facebook account..?
Remember I'm very new to this..
Best of regards
Thomas
The Facebook SDK for Android can be pretty complex for someone who is new to integrating Facebook into their app and especially for someone new to Android programming. The tutorials are very detailed but make frequent references to already created code so you would have to have that code (from the Facebook samples) in front of you to follow along.
However, with the new Facebook SDK, it is "pretty easy" just to log in. This is done with the LoginButton. Note, I put "pretty easy" in quotes because that certainly is a matter of opinion. Let me try to break it down into an easy to follow approach and highlight some important things and problems that I ran into.
First, take a look at the Getting Started page. Take a special look at step number 3 ("Import the SDK into Eclipse"), the end of step number 4 ("Run the Samples"), and step number 5 ("Create a Facebook App"). The end of step number 4 is where you generate the keyhash that you will use in the next step. Note, that when the command prompt code references openssl it means to put the entire path to the openssl application. If you do not have it you need to download it. Also, this step is important because it will not allow you to log-in unless it is correct.
Next, save the app id you received above (in step number 5 of getting started) and save it to a string resource like so:
<string name="app_id">YOUR_APP_ID_HERE</string>
Then, in your manifest file, put this below all the other Activity declarations but within the Application tag:
<activity android:name="com.facebook.LoginActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:label="#string/app_name" />
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/app_id"/>
Also, in your manifest, make sure you have the following permissions:
<uses-permission android:name="android.permission.INTERNET"/>
Now, within the layout xml file you want the LoginButton, put something like this:
<com.facebook.widget.LoginButton
android:id="#+id/login_button"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center_horizontal"/>
Finally, within your Activity or Fragment, you can set an OnErrorListener, like so:
// Set an error listener for the login button
LoginButton loginButton = (LoginButton) v.findViewById(R.id.login_button);
if (loginButton != null) {
loginButton.setOnErrorListener(new OnErrorListener() {
#Override
public void onError(FacebookException error) {
if (error != null && !(error instanceof FacebookOperationCanceledException)) {
// Failed probably due to network error (rather than user canceling dialog which would throw a FacebookOperationCanceledException)
((HangmanActivity) getActivity()).showError(getResources().getString(R.string.network_error), false);
}
}
});
}
You could put the above code either in the onCreate or onCreateView method. The above code sees if there is an error due to loss of internet connection. Now, if you run your application you should be able to hit the LoginButton and it will log you into facebook and then it will switch to say "Logout" (which when clicked again will log you out). And that's all there is to logging in, however, if you want to add more functionality I recommend taking a look at Facebook's other tutorials like this one. Note, that the tutorial I just stated makes references to a sample project that they have provided with the SDK. It also uses a lot of Fragments so make sure you are familiar with them too. Well, I hope that helps!

Eclipse's Android 'hover assist' not always working

I apologise if if 'hover assist' isn't the right terminology but I'm referring to the feature in Eclipse where if the use hovers the pointer over a method, a popup box appears with javadoc type information and invites the user to press F2 for focus. I see inconsistent behaviour for different methods, in that sometimes the browser gives me a file not found error when I click on a highlighted subject in that box.
I can best illustrate this by means of a snippet of code from a test project. I have the method:
#Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
... etc
...
}
If I hover over 'getSystemService' I see:
.
and then click on 'String' it takes me to the javadocs page
file:///C:/dev/tools/android-sdk-windows4.0/docs/reference/java/lang/String.html
on my machine in the browser. (I use the Firefox external browser) and this is just what I want.
However if I hover over the onCreate, I see:
Then if I click on the 'Bundle' link, I get this in the browser:
**File not found
Firefox can't find the file at /C:/dev/projects/EclipseIndigo/AndroidWorkTwo/CompassTwo/src/reference/android/os/Bundle.html.**
I have built the project with Android 2.3.3 jar and the javadoc properties show
which validates OK. I don't understand this inconsistent behaviour. Any help will be much appreciated.
The difference in both cases is the path "/docs/reference/java/" and "/src/reference/android/os/"
Please have a look at this url:
How to generate links to the android Classes' reference in javadoc?
It may guide you to correction.
Solved: I think it's just a plain Eclipse bug.
When I hover over the (overriden) onCreate the popup's header shows it belonging to my package and activity which extends Activity (as it must do)
If I click on the link inside the popup : Overrides: onCreate(...) in Activity
The the popup changes to show the same information but in class:
void android.app.Activity.onCreate(Bundle savedInstanceState)
Then, if I click on 'Bundle' in the new popup, all is well, we get the javadocs.
It's almost as if Eclipse thinks that the class Bundle itself has been overriden too and looks for the javadocs in my source.

Categories

Resources