appsflyer-flutter-plugin icon indicating copy to clipboard operation
appsflyer-flutter-plugin copied to clipboard

How to use this plugin in combination with segment

Open HerrNiklasRaab opened this issue 2 years ago • 3 comments

Hello together,

we are currently using Segment with the following plugin https://pub.dev/packages/flutter_segment and would like to integrate AppsFlyer, but we don't know how. Is there any getting started etc. for that use case? How is that possible?

Thank you so much for your response!

Best regards,

Niklas

HerrNiklasRaab avatar May 31 '22 14:05 HerrNiklasRaab

Here's how I solved this:

  • I installed both SDK's Appflyer's and Segment's
  • I only use Segment to track events
  • On my app initialization I do:

  final appsflyer_id = await appsFlyerSdk.getAppsFlyerUID();

  SegmentDefaultOptions.instance.options = {
    'integrations': {
      'AppsFlyer': {'appsFlyerId': appsflyer_id},
    }
  };


I also setup my callback this way:


  appsFlyerSdk.onInstallConversionData((res) async {
    Map<String, dynamic> payload = res['payload'];
    payload['appsflyer_id'] = appsflyer_id;
    unawaited(tracking.updateParameters(payload));
    await Segment.setContext({'campaign': payload});
  });
  

tracking is a sharedPrefs object that stores attribution data, so I can send it to other calls (or even directly to my db) if I want to.

brunapcat avatar Jul 20 '22 20:07 brunapcat

@brunapcat

To send information related to the campaign, do you have to configure something else in the segment destinations? For example, it sent the campaign information to the segment context but that information is not registered in appsflyer

DarwinVJ avatar Jul 27 '22 16:07 DarwinVJ

Don't know if I understood your question but you could manually add this info to context like I did, I set my await Segment.setContext({'campaign': payload}); every time my onInstallConversionData callback is called. If you just want to add this info somewhere else I'd suggest storing it on SharedPrefs through out your code.

brunapcat avatar Aug 02 '22 20:08 brunapcat