Beta version

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

Initial SDK setup

Minimum setup

To get started, you need to perform the following tasks:

Supported browsers

FollowAnalytics SDK supports Web Analytics and sending Web Push Notifications to desktop or mobile browsers. Web Analytics works on the following browsers:

Web Push Notifications works on the following browsers:

Install and configure 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

  1. Download the SDK from the SDK download page.

  2. Put the 2 javascript files fa-sdk-web.js and fa-sw-webpush.js in your website root folder.

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

    <script type='text/javascript' src="/fa-sdk-web.js"></script>
    <script type='text/javascript'>
        FAID: <YOUR_API_KEY>,
        bundleId: <YOUR_BUNDLE_ID>,
        workerUrl: '/fa-sw-webpush.js'

Replace <YOUR_API_KEY> by your API key, and <YOUR_BUNDLE_ID> by the unique identifier of your Web App in FollowAnalytics. Replace the workerUrl value with the location of your ServiceWorker file. If the .js files are not at the root of your domain you can specify their location using absolute URLs, like or relative paths, like /fa-sw-webpush.js.

Register for notifications

Web push notifications require HTTPS

Web push notifications can only be sent if your web domain is accessible through HTTPS.

Optimize your subscription rate

You should explain to your visitors the benefit of registering to your notifications before prompting them the popup which formally collects the permission. A user is much more likely to accept notifications if they know what they will receive, how frequently, and so on.

A push notification is a message that appears on the user’s screen and can be received even when your web page is not currently open in the user's browser.

In order for your Web Push Notifications to work, you must register it by calling:


If a user wants to unsubscribe from Web Push Notifications, you can do so by calling:



Logging best practices

To ensure your tags are relevant and will end up empowering your team through FollowAnalytics, please read the Logging best practices entry in the FAQ section.

Events vs Attributes

The FollowAnalytics SDK allows you to tag both events and attributes. If you are unsure about the difference, please refer to the corresponding FAQ entry.

Tag Events

The SDK allows you to log events happening in your code. These are the two methods you can call on the SDK:

FollowAnalytics.logEvent(name, arg)
FollowAnalytics.logError(name, arg)

Use the name as the unique identifier of your tag, use the details section to add context. Events can be renamed later: the name that you give to your event here can be overridden in the FollowAnalytics UI.

The details field can either be a String or a Hash, so that you can associate multiple key-values for additional context.

For instance, logging the appearance of a view could be done as the following examples:

FollowAnalytics.logEvent('Product view', 'Product reference')

var details = {firstParam: 'My first object detail', secondParam: 'My second object detail'}
FollowAnalytics.logEvent('Example log name', details)

User ID and attributes

You don't need a user ID to set attributes

Attributes are tied to the device when no user ID is provided. If a user ID is set, a profile is created and can be shared across your apps.

In both cases, attributes can be used in segments and campaigns to target users.

User ID

If users can sign in somewhere in your web app, you can specify their identifier to the SDK. This way, you will be able to build a profile in FollowAnalytics, send transactional campaigns, link your users with your other apps and even between FollowAnalytics and your CRM, and more.

This identifier is usually an e-mail address, client identifier, phone number, or anything else that uniquely ties your customers to you.

To register the user identifier, use:



If you want to remove the user identifier (in case of a sign out for instance) use the following method:


You can get the current user ID set by calling:



The Web SDK currently does not support attributes. It will in a future release.

Advanced use cases

Device ID

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


This method will return a string containing the deviceId value.

Optional initialization parameters

When initializing the SDK in your web app, you can pass the following parameters to customize its behavior: