Skip to content

Adobe Experience Platform - Analytics package for Unity apps.

License

Notifications You must be signed in to change notification settings

spoorthipujariadobe/unity-acpanalytics-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Adobe Experience Platform - Analytics plugin for Unity apps

Prerequisites

The Unity Hub application is required for development and testing. Inside of Unity Hub, you will be required to download the current version of the Unity app.

Download the Unity Hub. The free version works for development and testing, but a Unity Pro license is required for distribution. See Distribution below for details.

FOLDER STRUCTURE

Plugins for a Unity project use the following folder structure:

{Project}/Assets/Plugins/{Platform}

Installation

Usage

Initialization

Initialize by registering the extensions and calling the start function for core
using com.adobe.marketing.mobile;
using AOT;

[MonoPInvokeCallback(typeof(AdobeStartCallback))]
public static void HandleStartAdobeCallback()
{
    ACPCore.ConfigureWithAppID("1423ae38-8385-8963-8693-28375403491d");    
}

public class MainScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {   
        if (Application.platform == RuntimePlatform.Android) {
            ACPCore.SetApplication();
        }
        
        ACPCore.SetLogLevel(ACPCore.ACPMobileLogLevel.VERBOSE);
        ACPCore.SetWrapperType();
        ACPIdentity.RegisterExtension();
        ACPAnalytics.RegisterExtension();
        ACPCore.Start(HandleStartAdobeCallback);
    }
}

Analytics methods

Getting Analytics version:
ACPAnalytics.ExtensionVersion();

Send queued hits:

ACPAnalytics.SendQueuedHits();

Clear queued hits:

ACPAnalytics.ClearQueue();

Get the queue size:

[MonoPInvokeCallback(typeof(AdobeGetQueueSizeCallback))]
public static void HandleAdobeGetQueueSizeCallback(long queueSize)
{
    Debug.Log("Queue size is : " + queueSize);
}
ACPAnalytics.GetQueueSize(HandleAdobeGetQueueSizeCallback);

Get the tracking identifier

[MonoPInvokeCallback(typeof(AdobeGetTrackingIdentifierCallback))]
public static void HandleAdobeGetTrackingIdentifierCallback(string trackingIdentifier)
{
    Debug.Log("Tracking identifier is : " + trackingIdentifier);
}
ACPAnalytics.GetTrackingIdentifier(HandleAdobeGetTrackingIdentifierCallback);

Set the custom visitor identifier

ACPAnalytics.SetVisitorIdentifier("VisitorIdentifier");

Get the custom visitor identifier

[MonoPInvokeCallback(typeof(AdobeGetVisitorIdentifierCallback))]
public static void HandleAdobeGetVisitorIdentifierCallback(string visitorIdentifier)
{
    Debug.Log("Visitor identifier is : " + visitorIdentifier);
}
ACPAnalytics.GetVisitorIdentifier(HandleAdobeGetVisitorIdentifierCallback);

Running Tests

  1. Open the demo app in unity.
  2. Open the test runner from Window -> General -> TestRunner.
  3. Click on the PlayMode tab.
  4. Connect an Android or iOS device as we run the tests on a device in play mode.
  5. Select the platform for which the tests need to be run from File -> Build Settings -> Platform.
  6. Click Run all in player (platform) to run the tests.

Sample App

Sample App is located at unity-acpanalytics/ACPAnalytics/Assets/Demo. To build demo app for specific platform follow the below instructions.

Add core plugin
  • Download ACPCore-0.0.1-Unity.zip
  • Unzip ACPCore-0.0.1-Unity.zip
  • Import ACPCore.unitypackage via Assets->Import Package
Android
  1. Make sure you have an Android device connected.
  2. From the menu of the Unity app, select File > Build Settings...
  3. Select Android from the Platform window
  4. If Android is not the active platform, hit the button that says Switch Platform (it will only be available if you actually need to switch active platforms)
  5. Press the Build And Run button
  6. You will be asked to provide a location to save the build. Make a new directory at unity-acpanalytics/ACPAnalytics/Builds (this folder is in the .gitignore file)
  7. Name build whatever you want and press Save
  8. Unity will build an apk file and automatically deploy it to the connected device
iOS
  1. From the menu of the Unity app, select File > Build Settings...
  2. Select iOS from the Platform window
  3. If iOS is not the active platform, hit the button that says Switch Platform (it will only be available if you actually need to switch active platforms)
  4. Press the Build And Run button
  5. You will be asked to provide a location to save the build. Make a new directory at unity-acpanalytics/ACPAnalytics/Builds (this folder is in the .gitignore file)
  6. Name build whatever you want and press Save
  7. Unity will create and open an Xcode project
  8. From the Xcode project run the app on a simulator.
  9. If you get an error Symbol not found: _OBJC_CLASS_$_WKWebView. Select the Unity-iPhone target -> Go to Build Phases tab -> Add Webkit.Framework to Link Binary with Libraries.

Contributing

Looking to contribute to this project? Please review our Contributing guidelines prior to opening a pull request.

We look forward to working with you!

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

About

Adobe Experience Platform - Analytics package for Unity apps.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 69.3%
  • Objective-C++ 9.2%
  • Objective-C 8.9%
  • Makefile 7.7%
  • C 4.9%