The Acoustic Analytics Developer Hub

Welcome to the Acoustic Analytics developer hub. You'll find comprehensive guides and documentation to help you start working with Acoustic Analytics as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

How do I implement conditional initialization with the UI Capture SDK?

Some application situations need to initiate and terminate the capture functionality on various runtimes. For example, an application might require user consent before it begins capturing analytics data.

Overview

Skill Level: Intermediate

Prerequisites

Normally, the UI Capture library is required to capture all user interaction from page load to page unload. However, in certain application situations, it may be desirable to initiate and terminate this capture functionality depending on various runtime variables.

For example, consider an application that requires user consent before it begins capturing analytics data. In such a case, the application can choose to implement its application specific user interface to obtain such a consent. If consent is given then the application can invoke the initialization process of the UI Capture libary.

Step-by-step

  1. Locate the UI Capture configuration section. This section is normally found towards the end of the UI Capture JavaScript file.
  2. Replace the anonymous self-executing function which invokes the TLT.init() API with a named function which can be called at a later stage from within the application.
function initTealeafUIC() {
    "use strict";
    var TLT =
        window.TLT,
        changeTarget;

    if (TLT.getFlavor() ===
        "w3c" &&
        TLT.utils.isLegacyIE) {
        changeTarget =
            "input, select, textarea, button";
    }

    TLT.init({
                core: {
                    modules: {
                        overstat: {
                            events: [{
                                    name: "click",
                                    recurseFrames: true
                                },
                                {
                                    name: "mousemove",
                                    recurseFrames: true
                                },
                                {
                                    name: "mouseout",
                                    recurseFrames: true
                                },
                                {
                                    name: "submit",
                                    recurseFrames: true
                                }
                            ]
                        },

                        ...

                    });
            }
  1. With this change, UI Capture will not initialize automatically on page load.

    Rather, the named function initTealeafUIC() has to be explicitly invoked by the application in order to initialize UI Capture. The application can choose to invoke this function based on any runtime condition.

Expected outcome

Once initialized, UI Capture will continue operation until page unload. To terminate UI Capture at any time, invoke the TLT.destroy() API.

Updated 26 days ago


How do I implement conditional initialization with the UI Capture SDK?


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.