{"id":21478286,"url":"https://github.com/appsflyersdk/appsflyer-psn-unity-sample-app","last_synced_at":"2025-10-18T23:25:09.669Z","repository":{"id":183644472,"uuid":"670155968","full_name":"AppsFlyerSDK/appsflyer-psn-unity-sample-app","owner":"AppsFlyerSDK","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-24T08:18:50.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T17:57:15.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AppsFlyerSDK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-24T12:18:03.000Z","updated_at":"2023-07-25T07:54:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"b86aaba5-dbf1-4273-8021-7b1d48d8fb9c","html_url":"https://github.com/AppsFlyerSDK/appsflyer-psn-unity-sample-app","commit_stats":null,"previous_names":["appsflyersdk/appsflyer-psn-unity-sample-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-psn-unity-sample-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-psn-unity-sample-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-psn-unity-sample-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-psn-unity-sample-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AppsFlyerSDK","download_url":"https://codeload.github.com/AppsFlyerSDK/appsflyer-psn-unity-sample-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997164,"owners_count":20380982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-23T11:17:33.917Z","updated_at":"2025-10-18T23:25:09.548Z","avatar_url":"https://github.com/AppsFlyerSDK.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## AppsFlyer Playstation Unity SDK integration\n\nAppsFlyer empowers gaming marketers to make better decisions by providing powerful tools to perform cross-platform attribution.\n\nGame attribution requires the game to integrate the AppsFlyer SDK that records first opens, consecutive sessions, and in-app events. For example, purchase events.\nWe recommend you use this sample app as a reference for integrating the AppsFlyer SDK into your Unity Playstation game.\n\n\u003chr/\u003e\n\n## AppsflyerModule - Interface\n\n`AppsflyerModule.cs`, included in the scenes folder, contains the required code and logic to connect to AppsFlyer servers and report events.\n\n### AppsflyerModule\n\nThis method receives your API key, App ID, the parent MonoBehaviour and a sandbox mode flag (optional, false by default) and initializes the AppsFlyer Module.\n\n**Method signature**\n\n```c#\nAppsflyerModule(string devkey, string appid, MonoBehaviour mono, bool isSandbox = false)\n```\n\n**Usage**:\n\n```c#\n// for regular init\nAppsflyerModule afm = new AppsflyerModule(\u003c\u003c DEV_KEY \u003e\u003e, \u003c\u003c APP_ID \u003e\u003e, this);\n\n// for init in sandbox mode (reports the events to the sandbox endpoint)\nAppsflyerModule afm = new AppsflyerModule(\u003c\u003c DEV_KEY \u003e\u003e, \u003c\u003c APP_ID \u003e\u003e, this, true);\n```\n\n**Arguments**:\n\n- `DEV_KEY`: Get from the marketer or [AppsFlyer HQ](https://support.appsflyer.com/hc/en-us/articles/211719806-App-settings-#general-app-settings).\n- `APP_ID`: The app id on Appsflyer HQ\n\n### Start\n\nThis method sends first open/session requests to AppsFlyer.\n\n**Method signature**\n\n```c#\nvoid Start(bool skipFirst = false)\n```\n\n**Usage**:\n\n```c#\n// without the flag\nafm.Start();\n\n// with the flag\nbool skipFirst = [SOME_CONDITION];\nafm.Start(skipFirst);\n```\n\n### LogEvent\n\nThis method receives an event name and JSON object and sends an in-app event to AppsFlyer.\n\n**Method signature**\n\n```\nvoid LogEvent(string event_name, Dictionary\u003cstring, object\u003e event_parameters)\n```\n\n**Usage**:\n\n```c#\n// set event name\nstring event_name = \"af_purchase\";\n// set event values\nDictionary\u003cstring, object\u003e event_parameters = new Dictionary\u003cstring, object\u003e();\nevent_parameters.Add(\"af_currency\", \"USD\");\nevent_parameters.Add(\"af_price\", 6.66);\nevent_parameters.Add(\"af_revenue\", 12.12);\n// send logEvent request\nafm.LogEvent(event_name, event_parameters);\n```\n\n### IsInstallOlderThanDate\n\nThis method receives a date string and returns true if the game folder creation date is older than the date string. The date string format is: \"2023-03-01T23:12:34+00:00\"\n\n**Method signature**\n\n```c#\nbool IsInstallOlderThanDate(string datestring)\n```\n\n**Usage**:\n\n```c#\n// the creation date in this example is \"2023-03-23T08:30:00+00:00\"\nbool newerDate = afm.IsInstallOlderThanDate(\"2023-06-13T10:00:00+00:00\");\nbool olderDate = afm.IsInstallOlderThanDate(\"2023-02-11T10:00:00+00:00\");\n\n// will return true\nDebug.Log(\"newerDate:\" + (newerDate ? \"true\" : \"false\"));\n// will return false\nDebug.Log(\"olderDate:\" + (olderDate ? \"true\" : \"false\"));\n\n// example usage with skipFirst -\n// skipping if the install date is NOT older than the given date\nbool IsInstallOlderThanDate = afm.IsInstallOlderThanDate(\"2023-02-11T10:00:00+00:00\");\nafm.Start(!IsInstallOlderThanDate);\n```\n\n### GetAppsFlyerUID\n\nGet AppsFlyer's unique device ID. The SDK generates an AppsFlyer unique device ID upon app installation. When the SDK is started, this ID is recorded as the ID of the first app install.\n\n**Method signature**\n\n```c#\nvoid GetAppsFlyerUID()\n```\n\n**Usage**:\n\n```c#\nAppsflyerModule afm = new AppsflyerModule(\u003c\u003c DEV_KEY \u003e\u003e, \u003c\u003c APP_ID \u003e\u003e, this);\nafm.Start();\nstring af_uid = afm.GetAppsFlyerUID();\n```\n\n## Running the sample app\n\n1. Open Unity hub and open the project.\n2. Use the sample code in AppsflyerScript.cs and update it with your DEV_KEY and APP_ID.\n3. Add the AppsflyerScript to an empty game object (or use the one in the scenes folder):  \n   ![Request-OK](https://files.readme.io/b271553-small-EpicGameObject.PNG)\n4. Launch the sample app via the Unity editor and check that your debug log shows the following message:  \n   ![Request-OK](https://files.readme.io/7105a10-small-202OK.PNG)\n5. After 24 hours, the AppsFlyer dashboard updates and shows organic and non-organic installs and in-app events.\n\n## Implementing AppsFlyer in your Playstation game\n\n### Setup\n\n1. Add the script from `Assets/AppsflyerModule.cs` to your app.\n2. In the script above, [within these lines](https://github.com/AppsFlyerSDK/appsflyer-psn-unity-sample-app/blob/97b24f776d06b53d020438f8794cc8e4108d3d48/Assets/AppsflyerModule.cs#L51-L54), add PSN user ID for tracking or comment those in case you prefer not to collect it.\n3. Use the sample code in `Assets/AppsflyerScript.cs` and update it with your `DEV_KEY` and `APP_ID`.\n4. Initialize the SDK.\n\n```c#\nAppsflyerModule afm = new AppsflyerModule(\u003c\u003c DEV_KEY \u003e\u003e, \u003c\u003c APP_ID \u003e\u003e, this);\n```\n\n5. [Start](#start) the AppsFlyer integration.\n6. Report [in-app events](#logevent).\n\n## Resetting the attribution\n\n[Delete the PlayerPrefs data the registry/preferences folder](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html), or use [PlayerPrefs.DeleteAll()](https://docs.unity3d.com/2020.1/Documentation/ScriptReference/PlayerPrefs.DeleteAll.html) when testing the attribution in the UnityEditor.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fappsflyer-psn-unity-sample-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappsflyersdk%2Fappsflyer-psn-unity-sample-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fappsflyer-psn-unity-sample-app/lists"}