Web SDK Channel

The current SDK version is on release candidate. Though it has been thoroughly tested, you may experience inconsistant behaviour on some occasions.

Initial SDK Setup


Supported browsers



Initialize with your API key

Prepare your API key

Be sure to have your API key for this step of the configuration. If you are not sure where to find it, please reach out to your Customer Success Manager or message support@followanalytics.com

Copy this snippet into your the <head></head> of your site / application index.html page

<script type='text/javascript' src="https://s3-eu-west-1.amazonaws.com/fa-sdks/sdk-web/beta/latest/fa-sdk-web.js"></script>
<script type='text/javascript'>
  var FollowAnalytics = FollowAnalytics || {};
  //load fa sdk script asynchronously
  (function() {
    var falib = document.createElement('script');
    falib.type = 'text/javascript';
    falib.async = true;
    //enter url of script here
    falib.src = 'fa-sdk-web.js';
    falib.onload = function(){
      // initialize Fa Sdk
      FollowAnalytics.initialize({
        FAID: <YOU_API_KEY>,
        bundleId: <YOUR_BUNDLE_ID>,
      });
    };
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(falib, s);
  })();
</script>


Initialization parameters

Logging



Log Events


Apart from session duration, you may need to send specific logs on various events by using:

  FollowAnalytics.logEvent(name, arg)


* name String
Specify the name of the event * arg String | Object
You can add a 'string' or an object with keys / values to provide additional data to your log


Example with a string

  FollowAnalytics.logEvent('LogEventWithAString', 'This is a string event detail')


Example with an object

  FollowAnalytics.logEvent('LogEventWithAnObject', {firstParam: 'My first object detail', secondParam: 'My second object detail'})



You can also log errors with:

  FollowAnalytics.logError(name, arg)


* name String
Specify the name of the event * arg String | Object
You can add a 'string' or an object with keys / values to provide additional data to your log

User ID


If you have the possibility to identify a user you can use the following method to set the UserID of a user's session. Note that each time the UserId changes, the current session will close and a new one will start.

  FollowAnalytics.setUserId(userId)


* userId string | null


Example

  FollowAnalytics.setUserId('John Doe')



And you can get the userId value as well

  FollowAnalytics.getUserId()

This method will return a string containing the userId.

Device ID


You can get the deviceId value, which is a unique identifier generated on the very use of the SDK, and stored in local storage. As long as the user doesn't delete their local storage data, this value will persist.

  FollowAnalytics.getDeviceId()


This method will return a string containing the deviceId value

SDK Download



You can download the latest version here Web SDK V0.5.0