la-haus / flutter-segment

Segment.io library for flutter
MIT License
22 stars 138 forks source link

Facebook App Events Integration #54

Closed b099l3 closed 1 year ago

b099l3 commented 2 years ago

This PR adds Facebook App Events in a similar manner to Amplitude: You can now set a boolean to enable:

  Segment.config(
      options: SegmentConfig(
        writeKey: _writeKey,
        trackApplicationLifecycleEvents: true,
        facebookAppEventsIntegrationEnabled: true,
        debug: kDebugMode,
      ),
    );

You will need to add in this code too, to get Facebook to work, IDFA can be obtained via different package:

Segment.setContext({
      'device': {
        'adTrackingEnabled': adTrackingEnabled.toString(),
        'advertisingId': advertisingId,
      }
    });
danielgomezrico commented 2 years ago

Thanks for PR!

This PR is related to this issue:

We can not add all of the integrations at once :( We already have some and that's bad, we need to go in another direction, any chance that you give a look at that issue?

b099l3 commented 2 years ago

Cool, I'll take a look 👀

ariefwijaya commented 1 year ago

Thanks for PR!

This PR is related to this issue:

We can not add all of the integrations at once :( We already have some and that's bad, we need to go in another direction, any chance that you give a look at that issue?

Correct, but I think , if the integration only support device mode, then we must integrate it with our flutter-segment plugin. For e.g Firebase Analytics. it only support device mode so we are not able send anything to firebase without integrate it to our flutter-segment plugin

image
b099l3 commented 1 year ago

I'll close this PR as we are not going to take this any further

b099l3 commented 1 year ago

@ariefwijaya That may be the case, but the company I work for has a third party that deals with marketing/user aquistion kept saying that they needed the SDK installed for some analysis and to track installs: image

We contacted Segment and got this response from our customer rep:

Hey folks,

Niall here, one of the Success Engineers at Segment. Thanks for writing in! For this image:

image

Facebook is alerting you that you are sending data to them via their server side API. This is how our server side (cloud mode) integration works, it receives events from your source (client side) and then forwards the event to Facebook via a server side request. Some FB features may only work if their SDK is bundled on the client side, such as app Installs. This is really just a trade-off with server side connections. Hope that helps, and let me know if you have more questions! Niall Brennan | Customer Success Engineer @ Segment

Most importantly, "Some FB features may only work if their SDK is bundled on the client side, such as app Installs." so we switched to having the SDK installed. Not having the SDK might suffice for some of the events and other things.

ariefwijaya commented 1 year ago

@b099l3 Oh I See, Then, just add the fb client SDK to your app. it is not related to the flutter-segment library.

dgilperez commented 1 year ago

@b099l3 @ariefwijaya reading this very interested, we're having the same issue coming from our mkt team. Just to confirm I understood this correctly, you are using both flutter-segment + Segment - FB Events integration + added the FB SDK manually to the App? Did you do the 3 things and it all works for you?

ariefwijaya commented 1 year ago

@dgilperez OK, let me mention the Analytics function:

  1. Track events
  2. Track Screen
  3. Track user id and attributes
  4. Track App Lifecycle, like, app install, app update, opened, closed etc.

  5. Done by the Segment
  6. Done by the Segment, but some providers e.g. Facebook, Mixpanel and Moengage don't have this feature. But firebase analytics has it.
  7. Done by the Segment
  8. This is actually done by Segment when destination has Cloud Mode Integration, like Mixpanel. But some providers have to be installed to track app install, updates or anything depend on provider requirement. For e.g, Facebook, Firebase and Moengage must install device mode as well to track app install or updates.

Everything done by the segment means segment will forward the data to destinations.

dgilperez commented 1 year ago

Super clear @ariefwijaya, thanks a lot for the write up. Actually, I think it would be useful to add this to the README for others as well!

Just a last clarification, if I may 🙏 : on the 4th point, you did add the Facebook client and then used an explicit event from the flutter side or native side to track that lifecycle? or on the contrary it was sufficient to just install the SDK?

If it's the first case, I was looking at https://github.com/oddbit/flutter_facebook_app_events and https://github.com/saadfarhan124/flutter_facebook_sdk packages to easy the integration ...

ariefwijaya commented 1 year ago

No problem, @dgilperez In your case, If you are looking for tracking app install in facebook. You can use https://github.com/oddbit/flutter_facebook_app_events and what you need, just add the plugin properly in your project without adding any additional events, because it will be handled by Segment. Read more here https://segment.com/docs/connections/destinations/catalog/facebook-app-events/#facebook-events

image
dgilperez commented 1 year ago

Thanks a lot again for the responses. We are trying this next. 🙏