Unity Epic
Link to repository
GitHub
AppsFlyer Unity Epic SDK integration
AppsFlyer empowers gaming marketers to make better decisions by providing powerful tools to perform cross-platform attribution.
Game attribution requires the game to integrate the AppsFlyer SDK that records first opens, consecutive sessions, and in-app events. For example, purchase events.
We recommend you use this sample app as a reference for integrating the AppsFlyer SDK into your Unity Epic game.
AppsflyerEpicModule - Interface
AppsflyerEpicModule.cs
, included in the scenes folder, contains the required code and logic to connect to AppsFlyer servers and report events.
AppsflyerEpicModule
This method receives your API key, app ID and parent MonoBehaviour and initializes the AppsFlyer Module.
Chữ ký phương thức
AppsflyerEpicModule(string appid, string devkey, MonoBehaviour mono)
Usage:
AppsflyerEpicModule afm = new AppsflyerEpicModule("EPIC_APP_ID", "DEV_KEY", this);
Arguments:
EPIC_APP_ID
: Found in the Epic store linkDEV_KEY
: Get from the marketer or AppsFlyer HQ.
Start
This method sends first open/session requests to AppsFlyer.
Chữ ký phương thức
void Start(bool skipFirst = false)
Usage:
// without the flag
afm.Start();
// with the flag
bool skipFirst = [SOME_CONDITION];
afm.Start(skipFirst);
LogEvent
This method receives an event name and JSON object and sends an in-app event to AppsFlyer.
Chữ ký phương thức
void LogEvent(string event_name, Dictionary<string, object> event_parameters)
Usage:
// set event name
string event_name = "af_purchase";
// set event values
Dictionary<string, object> event_parameters = new Dictionary<string, object>();
event_parameters.Add("af_currency", "USD");
event_parameters.Add("af_price", 6.66);
event_parameters.Add("af_revenue", 12.12);
// send logEvent request
afm.LogEvent(event_name, event_parameters);
GetAppsFlyerUID
Nhận ID thiết bị duy nhất của AppsFlyer. SDK sẽ tạo ra một ID thiết bị duy nhất của AppsFlyer khi cài đặt ứng dụng. Khi SDK khởi động, ID này sẽ được ghi nhận là ID của lượt cài đặt ứng dụng đầu tiên.
Chữ ký phương thức
void GetAppsFlyerUID()
Usage:
AppsflyerEpicModule afm = new AppsflyerEpicModule("DEV_KEY", "EPIC_APP_ID", this);
afm.Start();
string af_uid = afm.GetAppsFlyerUID();
Running the sample app
- Open Unity hub and open the project.
- Use the sample code in AppsflyerEpicScript.cs and update it with your DEV_KEY and APP_ID.
- Add the AppsflyerEpicScript to an empty game object (or use the one in the scenes folder):
- Launch the sample app via the Unity editor and check that your debug log shows the following message:
- After 24 hours, the AppsFlyer dashboard updates and shows organic and non-organic installs and in-app events.
Implementing AppsFlyer in your Epic game
Setup
- Add EOS to your Unity project. Follow the Epic Online Services Unity plugin instructions and add it through your package manager.
- Add
EOSManager.cs
to a game object. - Add the script from
Assets/Scenes/AppsflyerEpicModule.cs
to your app. - Use the sample code in
Assets/Scenes/AppsflyerEpicScript.cs
and update it with yourDEV_KEY
andAPP_ID
. - Initialize the SDK.
AppsflyerEpicModule afm = new AppsflyerEpicModule("DEV_KEY", "EPIC_APP_ID", this);
- Start the AppsFlyer integration.
- Report in-app events.
Đã cập nhật khoảng 22 giờ trước