Social Data Tracking

Collecting Social Account Data

The Braze iOS SDK no longer automatically collects Facebook user data starting with version 2.10, and does not collect Twitter user data automatically with version 2.13. If you want to integrate Facebook user data in Braze user profiles, you need to fetch the user’s data and pass it to Braze.

You can get a user’s Facebook and Twitter data from the iOS system. You can also refer to the sample code for accessing Facebook accounts in class FacebookViewController, and Twitter account in class TwitterViewController in our Stopwatch sample application. If you were previously relying on the deprecated promptUserForAccessToSocialNetwork: method, see promptUserToConnectFacebookAccountOnDeviceAndFetchAccountData and promptUserToConnectTwitterAccountOnDeviceAndFetchAccountData for sample code on manually prompting your users for access to their social account data.

Another way to get a user’s Facebook data is from Facebook’s iOS SDK. For more information about integrating the Facebook SDK, follow the steps in Facebook SDK documentation.

Passing Facebook Data To Braze

Initialize ABKFacebookUser objects with the Facebook data you have collected and pass it to Braze:

1
2
ABKFacebookUser *facebookUser = [[ABKFacebookUser alloc] initWithFacebookUserDictionary:self.facebookUserProfile numberOfFriends:self.numberOfFacebookFriends likes:self.facebookLikes];
  [Appboy sharedInstance].user.facebookUser = facebookUser;
1
2
var facebookUser : ABKFacebookUser = ABKFacebookUser(facebookUserDictionary: facebookUserDictionary, numberOfFriends: numberOfFriends, likes: likes);
Appboy.sharedInstance().user.facebookUser = facebookUser;

In ABKFacebookUser’s init method initWithFacebookUserDictionary:numberOfFriends:likes:, all the parameters should be dictionaries and arrays returned directly from Facebook:

Parameter Definition
facebookUserProfile The dictionary returned from the endpoint “/me”.
numberOfFriends The length of the friends array returned from the endpoint “/me/friends”.
likes The array of user’s Facebook likes from the endpoint “/me/likes”.

For additional information regarding the Facebook Graph API, please refer to the Facebook Graph API Developer Documentation.

Additionally, you can tailor what Facebook data you’re sending to Braze, in case you don’t want to include the entire basic profile. For example:

1
ABKFacebookUser *facebookUser = [[ABKFacebookUser alloc] initWithFacebookUserDictionary:facebookUserPublicProfile numberOfFriends:-1 likes:nil];  

Passing Twitter Data To Braze

Initialize ABKTwitterUser objects, set up the Twitter data you have collected and pass it to Braze:

1
2
3
4
ABKTwitterUser *twitterUser = [[ABKTwitterUser alloc] init];
twitterUser.userDescription = self.userDescription;
twitterUser.twitterID = self.twitterID;
[Appboy sharedInstance].user.twitterUser = twitterUser;
1
2
3
4
var twitterUser : ABKTwitterUser = ABKTwitterUser();
twitterUser.userDescription = twitterDserDescription;
twitterUser.twitterID = twitterID;
Appboy.sharedInstance().user.twitterUser = twitterUser;

Recording Social Network Shares

As of SDK v.2.16, logSocialShare: has been deprecated. If you were relying on this method to log social shares, you can use logCustomEvent: instead.

WAS THIS PAGE HELPFUL?