Android - Facebook Event track Purchase - android

I'm working on implementing the Facebook tracking of Purchase event in Android. I followed the guide here https://developers.facebook.com/docs/app-events/android, and made a custom Bundle to send to FB.
The problem is, on the Facebook page of events, I don't see the Value column updated for the Purchase event.
This is the code:
Bundle parameters = new Bundle();
parameters.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, mCurrency);
parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_TYPE, mProductType);
parameters.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mPurchaseID);
Double valueToSum = 12.042289; //this is how the price looks like
AppEventsLogger logger = AppEventsLogger.newLogger(this);
logger.logEvent(AppEventsConstants.EVENT_NAME_PURCHASED, valueToSum, parameters);
My problem is that, the valueToSum does not sum in the Facebook Events page. It's always shown as "-".
Any ideas what I am actually doing wrong?
Much appreciated.

It takes a while for the data to update on the dashboard. Try checking it the next day or so ...

Related

Logging events via Firebase with GA4 in Android

In this manual Get started with Google Analytics there is a section "Start logging events":
Java code
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
Kotlin code:
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_ITEM) {
param(FirebaseAnalytics.Param.ITEM_ID, id)
param(FirebaseAnalytics.Param.ITEM_NAME, name)
param(FirebaseAnalytics.Param.CONTENT_TYPE, "image")
}
Questions:
Confusing between FirebaseAnalytics.Event.SELECT_CONTENT in Java the code and FirebaseAnalytics.Event.SELECT_ITEM in the Kotlin code.. The both parameters are different (SELECT_CONTENT vs SELECT_ITEM). Webpage about events: https://firebase.google.com/docs/analytics/events is Service Unavailable.
When I go to the: Firebase -> Analytics -> Events -> select_content: there is: Events in last 30 minutes. I cannot list of all events. I don't see the values of selected event.. I don't see all the select_content events includes values.
I tried to create custom dimension in Custom definitions, I waited 24 hours and I still don't know where to see the event.
Do you know, how to show all Events with values reported by FirebaseAnalytics.Event.SELECT_CONTENT ? Like in old Firebase before update? This is image of the old Firebase select_content:
The new Firebase logging events is not clear at all to me.
Similar post with unaswered good question:
Do you mean that you can get report for some type of select_content event by item_id? Did you try this?

Android - ConsentInformation - Could not parse Event FE preflight response

I ve seen this error posted in many places but no one has ever answered what needs to be done to fix it or why is it happening. I m hoping I ll have better luck.
ConsentInformation consentInformation = ConsentInformation.getInstance(getActivity());
String[] publisherIds = {"pub-**********~*******"};
consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
#Override
public void onConsentInfoUpdated(com.google.ads.consent.ConsentStatus consentStatus) {
//do something
}
#Override
public void onFailedToUpdateConsentInfo(String errorDescription) {
Log.e("GDPR ", errorDescription);
}
});
This is how I am using the consent sdk. I always get the same error: Could not parse Event FE preflight response
My import in gradle is implementation 'com.google.android.ads.consent:consent-library:1.0.6'
I am running this code on the OnCreateView method of the first fragment loaded. Also tried running a few seconds later in case it was a timing thing...still the same error.
Also tried adding the ca-app- prefix before the pub in publisher id...same result.
Any help is appreciated.
Make sure that you're using Publisher ID and not App ID
Publisher ID is the unique identifier for your AdMob account.
Looks something like this pub-7100389293873601
App ID is the unique ID assigned to your app. It looks something like this ca-app-pub-7100382293173983~6849306728.
You can have multiple App IDs (for each app) but you can only have one Publisher ID for your account.
You can find your publisher ID in you AdMob Settings:
Or make sure you pasted it correctly.
Hope this helps!
The Admob account I used was completely new and the "Could not parse Event FE preflight response" was displayed repeatedly. Only when I tried it with an older account it worked. I think you have to wait a bit for verification.
or
Another thing to try is add your payment information to your Admob account
like described in this answer https://stackoverflow.com/a/61423243/8779275 and also check the other points there.

Firebase Analytics even show up in log but not on firebase console

I am trying to integrate Firebase RemoteConfig and Analytics with my Android application. Remote configuration part is working but Analytics part is not working. Here is my build.gradle
// Firebase configuration
compile group:'com.google.firebase', name:'firebase-core', version: '9.4.0'
compile group:'com.google.firebase', name:'firebase-config', version: '9.4.0'
// Firebase analytics
compile 'com.google.android.gms:play-services-analytics:9.4.0'
Here is my Activity code.
FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(this);
firebaseAnalytics.setUserId("5107611364");
firebaseAnalytics.setUserProperty("custom_user_property", "custom_user_proerty_value");
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID, "SomeID");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "SomeIDName");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "IdType");
firebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
I am trying to publish customer property as well as the event but both of them are not working. I have enabled adb logging and I can see that custom event and property are published. These do not appear on the Firebase Analytics console even after 24hrs. I don't know what is wrong.
#Rakesh - you are looking in the wrong location. You are supplying customID feilds, in your example you are supplying CONTENT_TYPE : IdType. You don't need a minimum of 10 users to see the data...if you only have 1 user that data will appear within 24 hours of that user using your app.
I will say this, initially finding your own custom IDs is not very straight forward...it took me a while to find it too.
The place to find that custom reported info is: Anaylytics - Events - once on this page, click on the actual CONTENT_TYPE you are wishing to track, in your example above, it would be idType
Then on the Content graph you will see your customIDs (ie: someID)...click on someID. In my case (and in my screenshots) my equivelant someIDs are "field, button & select"
and then you will see all the data related to the values (someIDName) you passed into someID.
Now, if idType is not appearing for you then that may because Firebase isn't allowing you to create your own CONTENT_TYPE, I am not certain if you can do that as I have not tried...and in that case you would need to use a predefined CONTENT_TYPE. I am not using a custom idType, I am using CONTENT_TYPE : select_content.

What is a Page ID for the place field in Post Facebook Graph API?

I am having trouble while trying to post a message on the current end-user Facebook wall with my Android Application.
So far :
The user is logged in with all the required permissions, especially
the publish_actions permission ;
I am using the last version of Facebook SDK 3.x & Graph API v2 as of May 2014
Post to wall works now as of EDIT 2, but there are issues with
privacy settings : post cannot be seen by anyone not even the
recipient who is tagged in the post ! See EDIT 2 for more details
Here is the documentation for posting a message on the user wall :
https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed (go to Publishing)
Regarding the message that needs to be posted on the user' wall, I need to tag some friends that were previously selected by the user.
But to use the tag field I need to use the place field.
The documentation says :
Name: tags
Comma-separated list of user IDs of people tagged in this post. You cannot specify this field without also specifying a place.
Type: csv[string]
Name: place
Page ID of a location associated with this post.
Type: string
What is location page ID ? How do I get it ?
Oddly enough, in my specefic case, I am offering the possibilty to the user to share is upcoming travel on Facebook.
More oddly enough, this travel is defined by dates and a destination (name of destination + latitude & longitude). The user has the possibility to also share this travel to his friends that are located in his travel's destination hence the need to tag his friends to the wall post.
[EDIT 1]
After looking into #Tobi solutions, I managed to post a message on the end-user wall (in my case me, since I am the developper).
So far : the message is correctly displayed with a friend tagged (a dummy account I use for tests purpouses) and there is also the place : Paris, France.
Using the following search query (thanks #Tobi) search?q=Paris,France&type=place I can get the ID of Paris, France.
Since I did not code the part to retrieve the Place ID it put it manually in the code for the sake of testing the feature first.
[END OF EDIT 1]
[EDIT 2]
I noticed I forgot to add the part with the privacy values to my args Bundle. But it did not change a damn thing : my post is only visible to me alone.
Going to my Facebook wall, here is what I get :
Hovering the public parameters of the posts (a padlock icon) says "All tagged persons".
Clicking on the icon shows the list of settings with only "Only me" selected.
Why "only me" even though I specifically said me + my dummy account in the request parameters ?
Even weirder : changing the property of the publication parameters to "customized" with my dummy account does not change a damn thing as well. Just why ? Facebook is really getting on my nerve...
For the rest, the message content is correctly displayed and the related place is the good one. At least a got that correctly. But still, I just don't get the rest ...
[END OF EDIT 2]
So here is the updated code :
if (this.session != null && this.session.isOpened()) {
final Bundle args = new Bundle();
if (this.selectedContacts.isEmpty() == false) {
args.putString("message", message);
args.putString("place", "170558129707208"); //manually added Paris, France ID
String tags = "";
//here I made some modifications regarding the tags so that is built correctly
for (int it = 0; it < this.selectedContacts.size(); it++) {
final String name = this.selectedContacts.get(it).toString();
final String friendID = String.valueOf(getIdFromName(name)); // returns an int
if (it == this.selectedContacts.size())
tags += friendID;
else
tags += friendID + ",";
}
// Forgot to add privacy values to bundle !
final JSONObject privacyValues = new JSONObject(); //not android JSON, but JSON-Simple lib
privacyValues.put("value", "CUSTOM");
String allow = this.currentUser.getId() + "," + tags;
privacyValues.put("allow", allow); // to limit the visibility of this post
args.putString("privacy", privacyValues.toJSONString()); //forgot that one...
final Request shareTravelRequest = new Request(this.session, this.currentUser.getID() + "/feed",
args, HttpMethod.POST, new Request.Callback() {
public final void onCompleted(final Response response) {
//TODO
}
}
);
final Response response = shareTravelRequest.executeAndWait();
if (response.getError() == null) // in this case, no error occurred
return true;
else {
this.lastErrorMessage = response.getError().getErrorMessage();
Log.e("Something went wrong while posting Facebook message", this.lastErrorMessage);
Log.e("Error type is", response.getError().getErrorType());
Log.e("Error code is", String.valueOf(response.getError().getErrorCode()));
return false;
}
}
}
Unfortunately I must have mistaken somewhere because although the post does appear on my Facebook wall with my dummy account tagged and with the correct link to the place, my dummy account cannot see the post.
I tried creating manually the same post on my Facebook wall by using the following settings :
First I supplied a message
Second I supplied a place
Third I tagged my dummy account
Four I choose who can see this post : me and my dummy account
And finally, I post the message.
In this case, my dummy account sees the post both on its wall and on my wall.
So I would like to know what parameters I must get wrong because there is not much parameters and I just don't see why.
Thanks !
You can either use the Search and use the type place (https://developers.facebook.com/docs/graph-api/using-graph-api/v2.0#search), or, if you have positioning date, use an FQL query on the place table (https://developers.facebook.com/docs/reference/fql/place/) as described here: Facebook places: order results by distance
Use two test accounts made via Facebook Developer App settings and not a dummy account that breaks TOS. Since you request publish_actions you probably didn't submit the app for review. Unless your dummy account is a developer/tester in roles as well (which is breaking the TOS again) then your dummy account will not be able to see the post.
Only developers and testers of an unpublished application can see posts made by that application.

Android Facebook events invite

I'm developing an android application where I have to invite facebook friends to an event using Rest API.
Below is the code where I prepare bundle of parameters
Bundle eventInviteParams = new Bundle();
eventInviteParams.putString("method", "events.invite");
eventInviteParams.putString("eid", event.getFacebookEventId());
eventInviteParams.putString("personal_message", "Sample message");
String userIds = "";
for (int i = 0; i < facebookAdapter.getCount(); i++) {
FacebookUser user = facebookAdapter.getItem(i);
if (user.isSelected()) {
userIds += user.getId() + ",";
}
}
if (userIds.length() > 0) {
userIds = userIds.substring(0, userIds.length() - 1); // to remove last comma
eventInviteParams.putString("uids", userIds);
}
Then
response = mFacebook.request(eventInviteParams);
where mFacebook is Facebook api object.
The response is always
{"error_code":200,"error_msg":"Permissions
error","request_args":[{"key":"uids","value":"XXXXXXXXX,XXXXXXXXX"},{"key":"method","value":"events.invite"},{"key":"format","value":"json"},{"key":"eid","value":"XXXXXXXXXXX"},....]}
Application has following permissions
"email","publish_stream","read_stream","create_event","offline_access","user_events","friends_events","rsvp_event"
I want also to mention that I'm not event creator. I have searched on FCB docs and google but cannot find a proper answer.
Thank you very much for your response.
I continued with research and I found that the error
"error_code":200,"error_msg":"Permissions error"
was because I was not following the event. Once I RSVP to the event, I got the response false (I don't know why) and the error gone. I checked in Facebook and the given people were invited.
thanks
Only the user that has created the event can invite people to it. Even if the user has created the event with "Guests can invite friends" it seems that it is impossible to do it from an app. A few weeks ago I tried several methods to no avail!
The events.invite api is broken ..check it out on the facebook bugzilla http://bugs.developers.facebook.net/show_bug.cgi?id=17057

Categories

Resources