Flutter SDK Conversion Tracking
Conversion tracking in the Flutter SDK means reporting the acquisition cost of an install back to Magify, so it can be attached to the client's attribution data. The SDK exposes a setter for each of the two supported MMPs: Adjust and AppsFlyer.
Both setters require init to have completed, are write-only (there is no getter for
either), and never block the SDK: the first context request to the Magify backend goes out
without cost data if it hasn't arrived yet, and the remote config is reloaded once it does.
A call that fails local validation simply leaves the previously reported value in place.
Adjust cost data
Future<void> setAdjustCostData({double? amount, String? currency, String? type});
Call this from your Adjust attribution callback, passing along whatever cost fields Adjust reported for the install:
await MagifyClient.instance.setAdjustCostData(
amount: 2.5,
currency: 'USD',
type: 'cpi',
);
AppsFlyer cost data
Future<void> setAppsFlyerCostData(Map<String, Object> conversionInfo);
Pass the onConversionDataSuccess payload from the AppsFlyer SDK through as-is — the SDK
reads the fields it needs out of it:
cost_cents_USDis read first, if present.- Otherwise,
af_cost_valuetogether withaf_cost_currencyis used. - Either way,
af_cost_modelmust be one ofcpi,cpc,cpmorcpafor the cost data to be accepted.
Any other key in the map is ignored.
await MagifyClient.instance.setAppsFlyerCostData(conversionData);
Where conversionData is the Map<String, Object> your AppsFlyer plugin hands you in its
conversion-data callback.
Typical setup
Call the matching setter as soon as your MMP's attribution callback fires — typically once,
shortly after init completes:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await MagifyClient.instance.init(
const MagifyConfig(
applicationName: 'MyApplication',
defaultConfig: 'assets/magify_default_config.json',
isSandbox: false,
),
);
runApp(const MyApp());
}
// Elsewhere, inside your AppsFlyer conversion-data callback:
void onConversionDataSuccess(Map<String, Object> conversionInfo) {
MagifyClient.instance.setAppsFlyerCostData(conversionInfo);
}
Because neither setter blocks the first context request, it's fine for the attribution callback to fire after your app's first screen is already up — the SDK will simply reload its config once the cost data lands.
Next step
Continue to Configuration for the full set of SDK configuration options, including per-platform overrides.