Getting Started

1. Installation

  1. Download the WebEngageUnity.unitypackage
  2. Import the downloaded unitypackage into your Unity project through Assets > Import Package > Custom Package....

2. Initialization

  1. For Android, add the following meta-data tags in Assets/Plugins/Android/AndroidManifest.xml file of your Unity project.
<?xml version="1.0" encoding="utf-8"?>
<manifest
    ...>

    <application
    	...>

	    <meta-data android:name="com.webengage.sdk.android.key" android:value="YOUR-WEBENGAGE-LICENSE-CODE" />

	    <!-- true if development build else false -->
	    <meta-data android:name="com.webengage.sdk.android.debug" android:value="true" />

	    ...
	</application>
</manifest>

If 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.

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:label="@string/app_name"
        android:icon="@drawable/app_icon"
        android:allowBackup="false">

        <meta-data android:name="com.webengage.sdk.android.key" android:value="YOUR-WEBENGAGE-LICENSE-CODE" />

        <meta-data android:name="com.webengage.sdk.android.debug" android:value="true" />

        <activity
            android:name="com.unity3d.player.UnityPlayerActivity"
            android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">

            <intent-filter>

                <action
                    android:name="android.intent.action.MAIN" />

                <category
                    android:name="android.intent.category.LAUNCHER" />

                <category
                    android:name="android.intent.category.LEANBACK_LAUNCHER" />
            </intent-filter>

            <meta-data
                android:name="unityplayer.UnityActivity"
                android:value="true" />
        </activity>
    </application>
</manifest>

🚧

Note: Replace YOUR-WEBENGAGE-LICENSE-CODE with your own WebEngage license code.

  1. Initialize the WebEngage SDK at start of your application.
using WebEngageBridge;
...

public class YourScript : MonoBehaviour
{
    private void Awake()
    {
        WebEngage.Engage();
        ...
    }
    ...
}
  1. For iOS, add the following values in /Assets/Editor/WebEngagePostProcessBuild.cs file.
...

public class WebEngagePostProcessBuild
{
   [PostProcessBuild]
   public static void EditXcodePlist(BuildTarget buildTarget, string pathToBuiltProject)
   {
       if (buildTarget == BuildTarget.iOS)
       {
       	// Add your WebEngage license code
       	string WEBENGAGE_LICENSE_CODE = "YOUR-WEBENGAGE-LICENSE-CODE";

       	// Set debug log level
           string logLevel = "VERBOSE";
       	...
       }
   }
}

🚧

Note: Replace YOUR-WEBENGAGE-LICENSE-CODE with your own WebEngage license code.

  1. Initialize the WebEngage SDK in your AppDelegate.m class.
#import <WebEngage/WebEngage.h>
...

-(BOOL)application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) options
{
    [[WebEngage sharedInstance] application:application didFinishLaunchingWithOptions:options];
    
    ...
}

If you are not already implementing AppDelegate.m in your Unity app, then create a new file at /Assets/Plugins/iOS/OverrideAppDelegate.m and copy the content below in that file.

#import "UnityAppController.h"
#import <WebEngage/WebEngage.h>


@interface OverrideAppDelegate : UnityAppController
@end


IMPL_APP_CONTROLLER_SUBCLASS(OverrideAppDelegate)

@implementation OverrideAppDelegate

-(BOOL)application:(UIApplication*) application didFinishLaunchingWithOptions:(NSDictionary*) options
{
    [[WebEngage sharedInstance] application:application didFinishLaunchingWithOptions:options];
    
    return [super application:application didFinishLaunchingWithOptions:options];
}

@end

3. Attribution Tracking

Add the following receiver tag in the Assets/Plugins/Android/AndroidManifest.xml file for tracking app installs and user-acquisition attribute details.

<?xml version="1.0" encoding="utf-8"?>
<manifest
    ...>

    <application
        ...>

        ...

        <receiver
          android:name="com.webengage.sdk.android.InstallTracker"
          android:exported="true">
          <intent-filter>
             <action android:name="com.android.vending.INSTALL_REFERRER" />
          </intent-filter>
        </receiver>

        ...
    </application>
</manifest>

So, what's next?