Hybrid Guide for Oracle CX Core SDK

The Oracle CX Core SDK includes components that help you acquire a complete analytics picture when applications involve online embedded content, split visits, and inbound and outbound links.

WebViews embedded in a native app can generate Oracle CX Core SDK's events using JavaScript helper methods that interact with the native app to generate and send events, or using the Oracle Infinity JavaScript tag in the embedded web content to generate and send events. Follow these instructions to use JavaScript helper methods.

WebViews embedded in a native app can generate Oracle Infinity Analytics events by using JavaScript helper methods that interact with the native app to generate and send events, or by using the Oracle Infinity JavaScript tag in the embedded web content to generate and send events.

Generating events through the native application

WebViews embedded in a native app can generate Oracle Infinity events using JavaScript helper methods that interact with the native app to generate and send events, or using the Oracle Infinity JavaScript tag in the embedded web content to generate and send events. Follow these instructions to use JavaScript helper methods. The native app must implement the Oracle CX Core SDK, and contain embedded web content in a WebView.

  1. Add a custom JavascriptInterface class to the WebView to handle communication from JavaScript in the embedded web content to the native application.

    • For a basic implementation, use the enableORAInWebView helper method in the ORABaseDataCollector to add the Oracle Infinity custom ORABaseWebViewJavascriptInterface class:
    String URL = "file:///android_asset/WebContent/webViewContent.html";
    WebView wv = (WebView)findViewById(R.id.webView1);
    oraBaseDataCollector.enableORAInWebView(wv);
    wv.loadUrl(URL);
    • If your WebView uses his custom javascript interface class there is no problem you can add your javascript interfaces too:
    String URL = "file:///android_asset/WebContent/webViewContent.html";
    WebView wv = (WebView)findViewById(R.id.webView1);
    oraBaseDataCollector.enableORAInWebView(wv);
    wv.addJavascriptInterface(new SecondJSInterface(), "test2");
    wv.addJavascriptInterface(new ThirdJSInterface(), "test3");
    ...
    wv.loadUrl(URL);

  2. Add OracleCoreMobileLib.js to the content that will be loaded in the WebView. OracleCoreMobileLib.js is delivered as part of the Oracle CX Core SDK for Android.

  3. Use the Oracle CX Core SDK for Android to generate events. In the embedded web content, use the JavaScript helper functions of the OracleCoreMobileLib object to generate events through the native app. A JavaScript helper function exists for each of the event helper functions exposed in the native Oracle CX Core SDK. The JavaScript helper functions take the same arguments as the native helper functions.

    <?xml version="1.0" encoding="utf-8"?>
    <html>
    <head>
    <script type="text/javascript" src="js/OracleCoreMobileLib.js"></script>
    <script type="text/javascript">
    function sendActivityStartEvent() {
    var activityName = "OracleActivity";
    var customData = {
    customKey : "CustomValue"
    };
    (new OracleCoreMobileLib()).triggerActivityStartEvent(activityName, customData);
    }
    </script>
    </head>
    <body>
    <div>
    <input type="button" onclick="sendActivityStartEvent()" value="Click To Send"/>
    </div>
    </body>
    </html>

Generating events through the Oracle Infinity JavaScript

WebViews embedded in a native app can generate events by using the Oracle Infinity JavaScript tag in the embedded web content to generate and send events. Follow these instructions to use the Oracle Infinity JavaScript tag. The native app must implement the Oracle CX Core SDK, the web content must be tagged with the Oracle Infinity JavaScript tag, and you must be familiar with Android WebViews.

Note: Due to restrictions enforced by some versions of Android, the Oracle Infinity JavaScript tag is unable to read and write cookies if you are loading local content in the WebView using the file:/// protocol. For this reason, generating events through the JavaScript tag is only supported if the WebView content is hosted externally to the app and accessed over HTTP. If you are using content bundled with the app, we recommend that you use JavaScript helper methods, which interact with the native app to generate and send events. See: Generating events through the native application.

For more information, see:

  1. Enable JavaScript in the WebView.
  2. Append the ORASsession parameters to the URL of the embedded web content using the provided helper method. These parameters are parsed by the JavaScript plug-in in the embedded content and used to configure its user ID and session configuration.

    String URL = "file:///android_asset/WebContent/webViewContent.html";
    URL = ORABaseDataCollector.getInstance().appendSessionParamsToURL(URL);
    WebView wv = (WebView)findViewById(R.id.webView1);
    wv.getSettings().setJavaScriptEnabled(true);
    wv.loadUrl(URL);

  3. Add the oracle.id_receiver.js plugin to the JavaScript tag configuration on the embedded content.

    window.oracleAsyncInit = function () {
    var dcs = new Oracle.dcs().init({ dcsid: "<your_dcsid>",
    timezone: "<your_timezone>", plugins: {
    id_receiver: {
    src: "//s.oracle.com/js/oracle.id_receiver.js"
    }
    }
    });
    dcs.track();
    }

  4. Generate events using track and multiTrack as you would on a standard web page tagged with the Oracle Infinity JavaScript tag.