Skip to content

Attribution Events

Track user acquisition sources and campaign performance using attribution events in your Flutter app.

Attribution Setup

Configure attribution tracking in your Flutter app:

Integration Partners

Configure third-party attribution partners in your Flutter project:

AppsFlyer Integration

dart
import 'package:upshot_flutter/upshot_flutter.dart';
import 'package:appsflyer_sdk/appsflyer_sdk.dart';

class AppsFlyerIntegration {
  static AppsflyerSdk? _appsflyerSdk;

  static void initialize() {
    // Initialize AppsFlyer
    AppsFlyerOptions appsFlyerOptions = AppsFlyerOptions(
      afDevKey: "YOUR_DEV_KEY",
      appId: "YOUR_APP_ID",
      showDebug: true,
    );

    _appsflyerSdk = AppsflyerSdk(appsFlyerOptions);

    // Register attribution callback
    _appsflyerSdk!.conversionDataStream.listen((data) {
      _trackAppsFlyerAttribution(data);
    });

    // Start AppsFlyer
    _appsflyerSdk!.initSdk();
  }

  static void _trackAppsFlyerAttribution(Map<String, dynamic> data) {
    Map payload = {
                  UpshotAttribution.attributionSource: "Appsflyer",
                  UpshotAttribution.utmSource: "Source",
                  UpshotAttribution.utmMedium: "Medium",
                  UpshotAttribution.utmCampaign: "Campaign",
      };
      FlutterUpshotPlugin.createAttributionEvent(payload);
}

Adjust Integration

dart
import 'package:upshot_flutter/upshot_flutter.dart';
import 'package:adjust_sdk/adjust.dart';

class AdjustIntegration {
  static void initialize() {
    // Initialize Adjust
    AdjustConfig config = AdjustConfig(
      "YOUR_APP_TOKEN",
      AdjustEnvironment.production, // Use AdjustEnvironment.sandbox for testing
    );

    // Set attribution callback
    config.attributionCallback = (AdjustAttribution attribution) {
      _trackAdjustAttribution(attribution);
    };

    Adjust.start(config);
  }

  static void _trackAdjustAttribution(AdjustAttribution attribution) {
    Map payload = {
                  UpshotAttribution.attributionSource: "Adjust",
                  UpshotAttribution.utmSource: "Source",
                  UpshotAttribution.utmMedium: "Medium",
                  UpshotAttribution.utmCampaign: "Campaign",
      };
      FlutterUpshotPlugin.createAttributionEvent(payload);
  }
}

Custom Attribution Data

Track custom attribution parameters specific to your campaigns:

dart
import 'package:upshot_flutter/upshot_flutter.dart';
import 'dart:convert';

class CustomAttributionTracker {
  // Track custom attribution with additional parameters
  static void trackCustomAttribution({
    required String source,
    required String medium,
    required String campaign,
    String? content,
    String? term,
    Map<String, dynamic>? customData,
  }) {
    Map<String, dynamic> attributionData = {
      UpshotAttribution.attributionSource: "Adjust/Any other Attribution Platform",
      UpshotAttribution.utmSource: source,
      UpshotAttribution.utmCampaign: campaign,
      UpshotAttribution.utmMedium: medium,
      'attribution_content': content,
      'attribution_term': term,
      'timestamp': DateTime.now().millisecondsSinceEpoch,
    };

    // Add custom data if provided
    if (customData != null) {
      attributionData.addAll(customData);
    }
    FlutterUpshotPlugin.createAttributionEvent(attributionData);
  }
}

Powered by Upshot.ai