Setup

InApp templates offer most of the functions of FollowAnalytics through a Javascript interface. For example, it is possible to expand the tagging plan for user actions that happen inside the InApp message.

These functions are available through the FollowAnalytics object. In order to use this object, it is recommended to add the file fa-sdk.js inside the root folder of your template and link it from your html files.

After adding the link, you can use the FollowAnalytics object from the Javascript code of the template.

Example:

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="fa-sdk.js"></script>
    <script type="text/javascript">
      // Now we have access to the FollowAnalytics object
      FollowAnalytics.logEvent('MyTemplateHasBeenDisplayed');
    </script>
  </head>
  <body>

  </body>
</html>

You can download a mock implementation of the FollowAnalytics object here. Put a copy of this file in the root folder of the template. Remember that this is only a mock implementation, useful for offline development outside the context of the mobile application. In the mock implementation, all methods are forwarded to the browser's console. This way, we can verify that the correct methods are called during the development of the template.

Before the template is displayed inside the mobile application, this file is replaced by the actual implementation which will provide a bridge between Javascript and the native runtime of the SDK. Therefore, you shouldn't modify this file in any way; your modifications will be lost.

Method Reference

Current campaign

Closes the current campaign. Useful in order to implement custom close buttons.

Logs a special custom tag that is linked with the current campaign. These tags are collected by the server and the stats are visible inside the result page of the campaign.

The SDK bridge

Most of the standard functions of the SDK are available through the Javascript bridge. Here is a complete reference.

Returns the current user id.

Returns the current device id.

Returns the SDK version.

Returns the SDK platform (Android, iOS or Web).

Logs a custom event of the tagging plan.

Logs a custom error of the tagging plan.

User attributes

Clears the attribute. This is equivalent to setting the attribute to null.

Adds one or more elements to a set.

Removes one or more elements to a set.

Removes all the elements from a set