{"id":20340207,"url":"https://github.com/webengage/webengage-unity-android","last_synced_at":"2025-07-23T12:08:29.560Z","repository":{"id":82265229,"uuid":"181046028","full_name":"WebEngage/webengage-unity-android","owner":"WebEngage","description":"WebEngage Unity Package for Android apps built with Unity","archived":false,"fork":false,"pushed_at":"2022-08-26T10:08:42.000Z","size":2421,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-04T14:49:12.742Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/WebEngage.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}},"created_at":"2019-04-12T16:34:59.000Z","updated_at":"2022-08-26T09:19:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"d9ed7495-f7f1-490b-bbb1-d863a6ceb04d","html_url":"https://github.com/WebEngage/webengage-unity-android","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WebEngage/webengage-unity-android","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebEngage","download_url":"https://codeload.github.com/WebEngage/webengage-unity-android/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebEngage%2Fwebengage-unity-android/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266673580,"owners_count":23966375,"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-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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-14T21:20:13.985Z","updated_at":"2025-07-23T12:08:29.531Z","avatar_url":"https://github.com/WebEngage.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebEngage Unity Android\n\nWebEngage Unity Android plugin for Unity Android apps. This unitypackage is only for Android and would not work on any other platform.\n\n\n## Installation\n\n 1. Download the [WebEngageUnityAndroid.unitypackage](https://github.com/WebEngage/webengage-unity-android/raw/master/WebEngageUnityAndroid.unitypackage).\n\n 2. Import the downloaded unitypackage into your Unity project through `Assets` \u003e `Import Package` \u003e `Custom Package...`.\n\n 3. Replace the AAR file at `Assets/Plugins/Android/webengage-android-unity-X.X.X.aar` with the latest [webengage-android-unity.aar](https://github.com/WebEngage/webengage-unity-android/raw/master/Assets/Plugins/Android/webengage-android-unity-3.16.0.aar).\n\n\n## Update\n\n 1. Replace the AAR file at `Assets/Plugins/Android/webengage-android-unity-X.X.X.aar` with the latest [webengage-android-unity.aar](https://github.com/WebEngage/webengage-unity-android/raw/master/Assets/Plugins/Android/webengage-android-unity-3.16.0.aar).\n\n\n## Initialization\n\n1. Add the following meta-data tags in `Assets/Plugins/Android/AndroidManifest.xml` file of your Unity project.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest\n    ...\u003e\n\n    \u003capplication\n    \t...\n        android:allowBackup=\"false\"\u003e\n\n\t    \u003cmeta-data android:name=\"com.webengage.sdk.android.key\" android:value=\"YOUR-WEBENGAGE-LICENSE-CODE\" /\u003e\n\n\t    \u003c!-- true if development build else false --\u003e\n\t    \u003cmeta-data android:name=\"com.webengage.sdk.android.debug\" android:value=\"true\" /\u003e\n\n\t    ...\n\t\u003c/application\u003e\n\u003c/manifest\u003e\n```\n\nIf `AndroidManifest.xml` file does not exist in `Assets/Plugins/Android/` directory of your Unity project, then you can create a new `AndroidManifest.xml` file and copy the below content in it.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\u003e\n\n    \u003capplication\n        android:label=\"@string/app_name\"\n        android:icon=\"@drawable/app_icon\"\n        android:allowBackup=\"false\"\u003e\n\n        \u003cmeta-data android:name=\"com.webengage.sdk.android.key\" android:value=\"YOUR-WEBENGAGE-LICENSE-CODE\" /\u003e\n\n        \u003cmeta-data android:name=\"com.webengage.sdk.android.debug\" android:value=\"true\" /\u003e\n\n        \u003cactivity\n            android:name=\"com.unity3d.player.UnityPlayerActivity\"\n            android:configChanges=\"fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen\"\u003e\n\n            \u003cintent-filter\u003e\n\n                \u003caction\n                    android:name=\"android.intent.action.MAIN\" /\u003e\n\n                \u003ccategory\n                    android:name=\"android.intent.category.LAUNCHER\" /\u003e\n\n                \u003ccategory\n                    android:name=\"android.intent.category.LEANBACK_LAUNCHER\" /\u003e\n            \u003c/intent-filter\u003e\n\n            \u003cmeta-data\n                android:name=\"unityplayer.UnityActivity\"\n                android:value=\"true\" /\u003e\n        \u003c/activity\u003e\n    \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n**Note:** Replace YOUR-WEBENGAGE-LICENSE-CODE with your own WebEngage license code.\n\n\n2. Initialize the WebEngage SDK at start of your application.\n\n```csharp\nusing WebEngageBridge;\n...\n\npublic class YourScript : MonoBehaviour\n{\n    private void Awake()\n    {\n        WebEngage.Engage();\n        ...\n    }\n    ...\n}\n```\n\n\n## Attribution Tracking\n\nIn order to track 'App Installed' events and install-referrer URLs, follow the steps below.\n\n1. Make sure that you are using webengage-android-unity.aar version 3.16.0 or above.\n\n2. Download the latest version of [Android Install Referrer library (aar)](https://mvnrepository.com/artifact/com.android.installreferrer/installreferrer).\n\n3. Add the aar file to your Unity project at the location `/Assets/Plugins/Android/installreferrer-X.X.X.aar`.\n\n\n## Tracking Users\n\n1. Login and Logout\n\n```csharp\nusing WebEngageBridge;\n...\n\npublic class YourScript : MonoBehaviour\n{\n    ...\n\n    // User login\n    WebEngage.Login(\"userId\");\n\n    // User logout\n    WebEngage.Logout();\n}\n```\n\n2. Set system user attributes as shown below.\n\n```csharp\nusing WebEngageBridge;\n...\n\npublic class YourScript : MonoBehaviour\n{\n    // Set user first name\n    WebEngage.SetFirstName(\"John\");\n\n    // Set user last name\n    WebEngage.SetLastName(\"Doe\");  \n\n    // Set user email\n    WebEngage.SetEmail(\"john.doe@email.com\");\n\n    // Set user hashed email\n    WebEngage.SetHashedEmail(\"144e0424883546e07dcd727057fd3b62\");\n\n    // Set user phone number\n    WebEngage.SetPhoneNumber(\"+551155256325\");\n\n    // Set user hashed phone number\n    WebEngage.SetHashedPhoneNumber(\"e0ec043b3f9e198ec09041687e4d4e8d\");\n\n    // Set user gender, allowed values are ['male', 'female', 'other']\n    WebEngage.SetGender(\"male\");\n\n    // Set user birth-date, supported format: 'yyyy-mm-dd'\n    WebEngage.SetBirthDate(\"1994-04-29\");\n\n    // Set user company\n    WebEngage.SetCompany(\"Google\");\n\n    // Set opt-in status, channels: ['push', 'in_app', 'email', 'sms']\n    WebEngage.SetOptIn(\"push\", true);\n\n    // Set user location\n    double latitude = 19.0822;\n    double longitude = 72.8417;\n    WebEngage.SetLocation(latitude, longitude);\n}\n```\n\n3. Set custom user attributes as shown below.\n\n```csharp\nusing WebEngageBridge;\n    ...\n    // Set custom user attributes\n    WebEngage.SetUserAttribute(\"age\", 25);\n    WebEngage.SetUserAttribute(\"premium\", true);\n\n    // Set multiple custom user attributes\n    Dictionary\u003cstring, object\u003e customAttributes = new Dictionary\u003cstring, object\u003e();\n    customAttributes.Add(\"Twitter Email\", \"john.twitter@mail.com\");\n    customAttributes.Add(\"Subscribed\", true);\n    WebEngage.SetUserAttributes(customAttributes);\n```\n\n4. Delete custom user attributes as shown below.\n\n```csharp\nusing WebEngageBridge;\n    ...\n    \n    WebEngage.DeleteUserAttribute(\"age\");\n```\n\n\n## Tracking Events\n\nTrack custom events as shown below.\n\n```csharp\nusing WebEngageBridge;\n    ...\n\n    // Track simple event\n    WebEngage.TrackEvent(\"Product - Page Viewed\");\n\n    // Track event with attributes\n    Dictionary\u003cstring, object\u003e orderPlacedAttributes = new Dictionary\u003cstring, object\u003e();\n    orderPlacedAttributes.Add(\"Amount\", 808.48);\n    orderPlacedAttributes.Add(\"Product 1 SKU Code\", \"UHUH799\");\n    orderPlacedAttributes.Add(\"Product 1 Name\", \"Armani Jeans\");\n    orderPlacedAttributes.Add(\"Product 1 Price\", 300.49);\n    orderPlacedAttributes.Add(\"Product 1 Size\", \"L\");\n    orderPlacedAttributes.Add(\"Product 2 SKU Code\", \"FBHG746\");\n    orderPlacedAttributes.Add(\"Product 2 Name\", \"Hugo Boss Jacket\");\n    orderPlacedAttributes.Add(\"Product 2 Price\", 507.99);\n    orderPlacedAttributes.Add(\"Product 2 Size\", \"L\");\n    orderPlacedAttributes.Add(\"Delivery Date\", System.DateTime.ParseExact(\"2017-10-21 09:27:37.100\", \"yyyy-MM-dd HH:mm:ss.fff\", null));\n    orderPlacedAttributes.Add(\"Delivery City\", \"San Francisco\");\n    orderPlacedAttributes.Add(\"Delivery ZIP\", \"94121\");\n    orderPlacedAttributes.Add(\"Coupon Applied\", \"BOGO17\");\n    WebEngage.TrackEvent(\"Order Placed\", orderPlacedAttributes);\n\n    // Track complex event\n    Dictionary\u003cstring, object\u003e product1 = new Dictionary\u003cstring, object\u003e();\n    product1.Add(\"SKU Code\", \"UHUH799\");\n    product1.Add(\"Product Name\", \"Armani Jeans\");\n    product1.Add(\"Price\", 300.49);\n\n    Dictionary\u003cstring, object\u003e detailsProduct1 = new Dictionary\u003cstring, object\u003e();\n    detailsProduct1.Add(\"Size\", \"L\");\n    product1.Add(\"Details\", detailsProduct1);\n\n    Dictionary\u003cstring, object\u003e product2 = new Dictionary\u003cstring, object\u003e();\n    product2.Add(\"SKU Code\", \"FBHG746\");\n    product2.Add(\"Product Name\", \"Hugo Boss Jacket\");\n    product2.Add(\"Price\", 507.99);\n\n    Dictionary\u003cstring, object\u003e detailsProduct2 = new Dictionary\u003cstring, object\u003e();\n    detailsProduct2.Add(\"Size\", \"L\");\n    product2.Add(\"Details\", detailsProduct2);\n\n    Dictionary\u003cstring, object\u003e deliveryAddress = new Dictionary\u003cstring, object\u003e();\n    deliveryAddress.Add(\"City\", \"San Francisco\");\n    deliveryAddress.Add(\"ZIP\", \"94121\");\n\n    Dictionary\u003cstring, object\u003e orderPlacedAttributes = new Dictionary\u003cstring, object\u003e();\n    List\u003cobject\u003e products = new List\u003cobject\u003e();\n    products.Add(product1);\n    products.Add(product2);\n\n    List\u003cstring\u003e coupons = new List\u003cstring\u003e();\n    coupons.Add(\"BOGO17\");\n\n    orderPlacedAttributes.Add(\"Products\", products);\n    orderPlacedAttributes.Add(\"Delivery Address\", deliveryAddress);\n    orderPlacedAttributes.Add(\"Coupons Applied\", coupons);\n\n    WebEngage.TrackEvent(\"Order Placed\", orderPlacedAttributes);\n```\n\n\n## Push Notifications\n\n#### 1. Using FCM Unity Plugin\n\n1. Import FCM Unity plugin as instructed [here](https://firebase.google.com/docs/cloud-messaging/unity/client) into your Unity project.\n\n2. If you have replaced the `Assets/Plugins/Android/AndroidManifest.xml` then make sure to add back your WebEngage license-code and debug-mode meta-data tags in the `AndroidManifest.xml` file.\n\n3. In your script where you have registered callbacks for `OnTokenReceived` and `OnMessageReceived`, add the following code snippets.\n\n```csharp\nusing WebEngageBridge;\n    ...\n    Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =\u003e {\n        var dependencyStatus = task.Result;\n        if (dependencyStatus == Firebase.DependencyStatus.Available)\n        {\n            Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;\n            Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;\n        }\n        else\n        {\n            ...\n        }\n    });\n    \n    public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token)\n    {\n        ...\n        WebEngage.SetPushToken(token.Token);\n    }\n\n    public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e)\n    {\n        Dictionary\u003cstring, string\u003e data = new Dictionary\u003cstring, string\u003e(e.Message.Data);\n        if (data.ContainsKey(\"source\") \u0026\u0026 \"webengage\".Equals(data[\"source\"]))\n        {\n            WebEngage.SendPushData(data);\n        }\n        ...\n    }\n```\n\nPush notifications will work as expected when app is in foreground.\n\n**Note**: Drawback of this approach is that push notifications will not be shown when app is in background. However those push notifications are cached and will be shown on next app launch. If you wish to prevent this drawback, then follow the Overriding FCM Unity Plugin approach given below.\n\n#### 2. Overriding FCM Unity Plugin\n\n1. Import FCM Unity plugin as instructed [here](https://firebase.google.com/docs/cloud-messaging/unity/client) into your Unity project.\n\n2. If you have replaced the `Assets/Plugins/Android/AndroidManifest.xml` then make sure to add back your WebEngage license-code and debug-mode meta-data tags in the `AndroidManifest.xml` file.\n\n3. Download and add the [webengage-android-fcm.aar](https://github.com/WebEngage/webengage-unity-android/raw/master/webengage-android-fcm-0.0.1.aar) file in `Assets/Plugins/Android/` directory of your Unity project.\n\n4. Add the following service tag in your `Assets/Plugins/Android/AndroidManifest.xml` file as shown below.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest\n    ...\u003e\n\n    \u003capplication\n        ...\u003e\n\n        \u003cservice android:name=\"com.webengage.android.fcm.WebEngageFirebaseMessagingService\"\u003e\n            \u003cintent-filter\u003e\n                \u003caction android:name=\"com.google.firebase.MESSAGING_EVENT\" /\u003e\n            \u003c/intent-filter\u003e\n        \u003c/service\u003e\n\n        ...\n    \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\n5. Update the FCM registration token on app start as shown below.\n\n```csharp\nusing WebEngageBridge;\n    ...\n\n    WebEngage.UpdateFcmToken();\n```\n\n\n## In-app Notifications\n\nNo additional steps are required for in-app notifications.\n\n### Tracking Screens\n\n```csharp\nusing WebEngageBridge;\n    ...\n    \n    // Set screen name\n    WebEngage.ScreenNavigated(\"Purchase Screen\");\n\n    // Update current screen data\n    Dictionary\u003cstring, object\u003e currentData = new Dictionary\u003cstring, object\u003e();\n    currentData.Add(\"productId\", \"~hs7674\");\n    currentData.Add(\"price\", 1200);\n    WebEngage.SetScreenData(currentData);\n\n    // Set screen name with data\n    Dictionary\u003cstring, object\u003e data = new Dictionary\u003cstring, object\u003e();\n    data.Add(\"productId\", \"~hs7674\");\n    data.Add(\"price\", 1200);\n    WebEngage.ScreenNavigated(\"Purchase Screen\", data);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebengage%2Fwebengage-unity-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebengage%2Fwebengage-unity-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebengage%2Fwebengage-unity-android/lists"}