{"id":21478317,"url":"https://github.com/appsflyersdk/appsflyer-meta-quest2-unity-sample-app","last_synced_at":"2025-07-31T02:41:29.493Z","repository":{"id":190206995,"uuid":"679784710","full_name":"AppsFlyerSDK/appsflyer-meta-quest2-unity-sample-app","owner":"AppsFlyerSDK","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-14T08:35:49.000Z","size":674,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-07T18:06:35.148Z","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-17T15:58:17.000Z","updated_at":"2023-08-17T15:58:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"29c034cf-e6e1-436d-b849-a66d3d516d89","html_url":"https://github.com/AppsFlyerSDK/appsflyer-meta-quest2-unity-sample-app","commit_stats":null,"previous_names":["appsflyersdk/appsflyer-meta-quest2-unity-sample-app"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/AppsFlyerSDK/appsflyer-meta-quest2-unity-sample-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-meta-quest2-unity-sample-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-meta-quest2-unity-sample-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-meta-quest2-unity-sample-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-meta-quest2-unity-sample-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AppsFlyerSDK","download_url":"https://codeload.github.com/AppsFlyerSDK/appsflyer-meta-quest2-unity-sample-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AppsFlyerSDK%2Fappsflyer-meta-quest2-unity-sample-app/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267978170,"owners_count":24175250,"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","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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:41.637Z","updated_at":"2025-07-31T02:41:29.391Z","avatar_url":"https://github.com/AppsFlyerSDK.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: Meta Quest 2 Unity\nparentDoc: 64e60f96a147a4004b5543e2\ncategory: 6446526dddf659006c7ea807\norder: 1\nhidden: false\nslug: meta-quest2-unity\n---\n\n\u003e Link to repository  \n\u003e [GitHub](https://github.com/AppsFlyerSDK/appsflyer-meta-quest2-unity-sample-app)\n\n## AppsFlyer Meta Quest Unity SDK integration\n\nIntegrate your Meta Quest Unity app or game with AppsFlyer to measure the performance of campaigns marketing these apps.\n\nGame attribution and user measurement require the game to integrate an AppsFlyer SDK that records first opens, sessions, and in-app events. For example, purchase events.\n\n\u003chr/\u003e\n\n## Prerequisites\n- Unity 2021.3.16f1\n- The Oculus SDK: Follow the [Oculus SDK for Unity integration guide](https://developer.oculus.com/documentation/unity/unity-gs-overview/).\n- Oculus Quest 2/3 Headset\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**Arguments**:\n\n- `string DEV_KEY`: Get from the marketer or [AppsFlyer HQ](https://support.appsflyer.com/hc/en-us/articles/211719806-App-settings-#general-app-settings).\n- `string QUEST_APP_ID`: Your Quest Store app ID. For Quest 2/3, this is the number in the store URL. For example: https://www.oculus.com/experiences/quest/XXXXXXXXXXXXXXXX/.\n- `MonoBehaviour mono`: The parent MonoBehaviour.\n- `bool isSandbox`: Flag that determines whether to activate sandbox mode. False by default. This option is for debugging. With the sandbox mode, AppsFlyer dashboard doesn't show the data. \n\n**Usage**:\n\n```c#\n// for regular init\nAppsflyerModule afm = new AppsflyerModule(\u003c\u003c DEV_KEY \u003e\u003e, \u003c\u003c QUEST_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 QUEST_APP_ID \u003e\u003e, this, true);\n```\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**Arguments**\n\n- `bool skipFirst`: Determines whether or not to skip first open events and send session events. The value is false by default. If true , first open events are skipped and session events are sent. [See example](#skipFirstExample)\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### Stop\n\nThis method stops the SDK from functioning and communicating with AppsFlyer servers. It's used when implementing user opt-in/opt-out.\n\n**Method signature**\n\n```c#\nvoid Stop()\n```\n\n**Usage**:\n\n```c#\n// Starting the SDK\nafm.Start();\n// ...\n// Stopping the SDK, preventing further communication with AppsFlyer\nafm.Stop();\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```c#\nvoid LogEvent(\n      string event_name,\n      Dictionary\u003cstring, object\u003e event_parameters,\n      Dictionary\u003cstring, object\u003e event_custom_parameters = null\n   )\n```\n\n**Arguments**:\n\n- `string event_name`: The name of the event.\n- `Dictionary\u003cstring, object\u003e event_parameters`: Dictionary object that contains the [predefined event parameters](https://dev.appsflyer.com/hc/docs/ctv-log-event-event-parameters).\n- `Dictionary\u003cstring, object\u003e event_custom_parameters`: [Optional] Dictionary object which contains the any custom event parameters.\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_revenue\", 12.12);\n// send logEvent request\nafm.LogEvent(event_name, event_parameters);\n\n// send logEvent request with custom params\nDictionary\u003cstring, object\u003e event_custom_parameters = new Dictionary\u003cstring, object\u003e();\nevent_custom_parameters.Add(\"goodsName\", \"新人邀约购物日\");\nafm.LogEvent(event_name, event_parameters, event_custom_parameters);\n```\n\n\n### SetCustomerUserId\n\nThis method sets a customer ID that enables you to cross-reference your unique ID with the AppsFlyer unique ID and other device IDs. **Note**: You can only use this method before calling `Start()`.\nThe customer ID is available in raw data reports and in the postbacks sent via API.\n\n**Method signature**\n\n```c++\nvoid SetCustomerUserId(string cuid)\n```\n\n**Arguments**:\n\n- `string cuid`: Custom user id.\n\n**Usage**:\n\n```c++\nAppsflyerModule afm = new AppsflyerModule(\u003c\u003c DEV_KEY \u003e\u003e, \u003c\u003c QUEST_APP_ID \u003e\u003e, this);\nafm.SetCustomerUserId(\"TestCUID\");\nafm.Start();\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**Arguments**:\n\n- `string datestring`: Date string in `yyyy-mm-ddThh:mm:ss+hh:mm` format.\n\n\n**Usage**:\n\u003cdiv id=\"skipFirstExample\"\u003e\u003c/div\u003e\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 the AppsFlyer 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 QUEST_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 QUEST_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 messages:  \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 Meta Quest game\n\n### Setup\n\n1. Add the script from `Assets/AppsflyerModule.cs` to your app.\n2. Use the sample code in `Assets/AppsflyerScript.cs` and update it with your `DEV_KEY` and `QUEST_APP_ID`.\n3. Initialize the SDK.\n\n```c#\nAppsflyerModule afm = new AppsflyerModule(\u003c\u003c DEV_KEY \u003e\u003e, \u003c\u003c QUEST_APP_ID \u003e\u003e, this);\n```\n\n6. [Start](#start) the AppsFlyer integration.\n7. Report [in-app events](#logevent).\n\n## Resetting the attribution\n\n[Delete the PlayerPrefs data in the registry/preferences folder](https://docs.unity3d.com/ScriptReference/PlayerPrefs.html), or use the [PlayerPrefs.DeleteAll()](https://docs.unity3d.com/2020.1/Documentation/ScriptReference/PlayerPrefs.DeleteAll.html) function when testing the attribution in the UnityEditor.\n![AF guid \u0026 counter in the Windows Registry](https://files.readme.io/51b1681-image.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fappsflyer-meta-quest2-unity-sample-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappsflyersdk%2Fappsflyer-meta-quest2-unity-sample-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsflyersdk%2Fappsflyer-meta-quest2-unity-sample-app/lists"}