Unity

Add Fload's attribution package to a Unity game for iOS and Android. It calls Fload's native SDKs underneath, so it behaves exactly like them.


What you need

  • Unity 2021.3 or later.
  • iOS 15 or later, and Android API 24 or later.
  • Your app's write key.
  • RevenueCat's Unity SDK in your game, if you want revenue per keyword. Fload's package doesn't depend on it.

Beta. The Unity package is new. Test a build on a real iPhone and a real Android phone before you ship it, and tell support@fload.com if anything looks off.


1. Add the package

In Unity, open Window → Package Manager, click +, choose Add package from git URL, and enter the URL with a version pin:

text
https://github.com/fload-ai/fload-attribution-unity.git#1.1.1

Or add it to Packages/manifest.json:

json
{
  "dependencies": {
    "com.fload.attribution": "https://github.com/fload-ai/fload-attribution-unity.git#1.1.1"
  }
}

2. Set up iOS and Android

  • iOS: in Player Settings → iOS, set Target minimum iOS Version to 15.0. The build stops with a clear message if it's lower. There's no CocoaPods step: the package carries the iOS SDK's sources.
  • Android minimum: in Player Settings → Android → Other Settings, set Minimum API Level to Android 7.0 (API level 24) or higher. Unity's default is lower (22, or 23 in Unity 6), and the Android build fails below 24.
  • Android: check whether your project has the External Dependency Manager for Unity (EDM4U). Firebase, AdMob and most Google SDKs bring it: look for com.google.external-dependency-manager in Packages/manifest.json, or an Assets/ExternalDependencyManager folder. Then follow the matching step below.
  • Android with EDM4U: run Assets → External Dependency Manager → Android Resolver → Resolve. The package's own dependency file adds com.fload:attribution:1.1.0 from Maven Central. Add nothing else for Android.
  • Android without EDM4U: in Player Settings → Android → Publishing Settings, tick Custom Main Gradle Template, then add the SDK from Maven Central. Unity's Gradle templates already list mavenCentral() among the repositories, so no repository line is needed:
groovy
// Assets/Plugins/Android/mainTemplate.gradle
dependencies {
    implementation 'com.fload:attribution:1.1.0'
}

It is the same artifact EDM4U adds, so adding EDM4U to the project later needs no change.


3. Start it on the first scene

Call FloadAttribution.Configure once, as the game starts. Awake on an object in your first scene is a good place.

csharp
using Fload.Attribution;
using UnityEngine;

public class AttributionStart : MonoBehaviour
{
    void Awake()
    {
        FloadAttribution.Configure("fload_pk_…");
    }
}

Configure throws an ArgumentException if the key is empty.


Pass RevenueCat's app user id once RevenueCat is set up, and again after each login:

csharp
var purchases = GetComponent<Purchases>();
FloadAttribution.SetUserId(purchases.GetAppUserId());

5. Check it works

Turn on debug logs while you test:

csharp
FloadAttribution.Configure("fload_pk_…", new FloadOptions { LogLevel = FloadLogLevel.Debug });

In the Editor, the calls check their arguments and send nothing. Build to a real iPhone and a real Android phone, and look for the native logs: the subsystem com.fload.attribution on iOS, and the Logcat tag FloadAttribution on Android. Remove the debug option before you ship.


6. Ship it

Ship a new store build, and fill in Privacy for both stores.


Reference

CallWhat it does
FloadAttribution.Configure(key, options?)Starts the SDK. Call once, as the game starts
FloadAttribution.SetUserId(id)Links your user id to this install. Throws on null
FloadAttribution.InstallReferenceThis install's random reference, for support questions. null until the SDK has loaded
new FloadOptions { LogLevel = … }FloadLogLevel.Debug and the other levels, for testing