JS Doc

Core plugin

core:updateDeviceInfo

Use this command whenever you want to update the current user's information. Some fields, that we use internally, are filtered.

Argument Required Type Description
options yes <object> a list of fields <string> with value <string|number>
callbacks optional <object>
  • "onSuccess" : <void> 
  • "onError" : <string> label error

For example

ACC.push([
    "core:updateDeviceInfo",
    {
        "field1": "value1",
        "field2": "value2"
    }
]);

core:getDeviceID

Use this command to retrieve the current user device ID.

Argument Required Type Description

options

not used    
callbacks yes <object>
  • "onSuccess" : <string> device ID
  • "onError" : <string> label error while retrieving the user device ID

For example

ACC.push([
    "core:getDeviceID",
    null,
    {
        "onSuccess": function(deviceID) {
            console.log( "user device ID : " + deviceID );
        }
    }
]);

core:isCompliantWithPushPlugin

Use this command to know if the user is compliant with the Push Plugin

Argument Required Type Description

options

not used    
callbacks yes <object>
  • "onSuccess" : <void>
  • "onError" : <void>

For example

ACC.push([
    "core:isCompliantWithPushPlugin",
    null,
    {
        "onSuccess": function() {
            console.log( "this user is compliant with the push plugin !" );
        },
        "onError": function() {
            console.log( "this user is NOT compliant with the push plugin" );
        }
    }
]);

core:addCustomListeners

Use this command to register your custom listeners to an event triggered by the library

Argument Required Type Description
options yes <object>

a list of event names <string> with listener <function>. Available Core plugin events :

  • "sdkLoaded" : <object> this event is retroactive, i.e. if you use this command after the library has been loaded, your provided listener will be triggered. It is also a one time event. It returned a object containing the set configuration of your application
callbacks optional <object>
  • "onSuccess" : <array> returning the events that have been listened
  • "onError" : <string> label expliciting the reason why no events have been listened

For example

ACC.push([
    "core:addCustomListeners",
    {
        "sdkLoaded": function(config) {
            console.log( "SDK is loaded !", config );
        }
    }
]);

Push plugin

push:showAlert

Use this command when you want to show the HTML alert to the opt-out user.

Argument Required Type Description
options optional <object>

a new set of parameters that can override the configuration of your application (see the "alert configuration" section to check all the possibilities)

callbacks optional <object>
  • "onSuccess" : <void>
  • "onError" : <string> label error

For example

ACC.push([
    "push:isOptin",
    null,
    {
        "onSuccess": function(res) {
            console.log( "this user is optin since " + res.details.firstOptinDate );
        },
        "onError": function(err) {
            var isHardOptout = (err.details.notificationPermission === 'denied');
            if (isHardOptout) {
                console.log( "this user is hard optout: notification permission has been denied, we cannot ask him to be optin" );
            } else {
                console.log( "this user is soft optout: we can ask him to be optin" );
                ACC.push(["push:showAlert"]);
                
            }
        }
    }
]);


/*********************************/

// or, let's say you have a configuration so that every alert are injected with a specific content
// for this command execution, you can provide other contents (or any other options !):
var params = {
    theme: "modern",
    contents: {
        misc: "a unique content can be now display!"
    }
};
ACC.push([
    "push:isOptin",
    null,
    {
        "onSuccess": function(res) {
            console.log( "this user is optin since " + res.details.firstOptinDate );
        },
        "onError": function(err) {
            var isHardOptout = (err.details.notificationPermission === 'denied');
            if (isHardOptout) {
                console.log( "this user is hard optout: notification permission has been denied, we cannot ask him to be optin" );
            } else {
                console.log( "this user is soft optout: we can ask him to be optin" );
                ACC.push(["push:showAlert", params]);
                
            }
        }
    }
]);

push:launchLandingOnClick

Use this command to bind one or more DOM Anchor Elements (</a> tag) to launch the optout-to-optin landing page on click.

Argument Required Type Description
options yes <array> of <string> containing selected anchors to bind. The value must start with "#" or "." (ID or ClassName)
callbacks optional <object>
  • "onSuccess" : <array> provided elements that have been utterly binded
  • "onError" <string> label error

For example

ACC.push([
    "push:launchLandingOnClick",
    [
        "#myLink",
        ".myOtherLinks"
    ]
]);

push:requestBrowserPermission

Use this command to bind one or more DOM Anchor Elements (</a> tag) to display the native push browser's permission (from SDK 3.3.x)

Argument Required Type Description
options yes <array> of <string> containing selected anchors to bind. The value must start with "#" or "." (ID or ClassName)
callbacks optional <object>
  • "onSuccess" : <array> provided elements that have been utterly binded
  • "onError" <string> label error

For example

ACC.push([
    "push:requestBrowserPermission",
    [
        "#myLink",
        ".myOtherLinks"
    ]
]);

In scenario none, If you want to avoid displaying automatically the native permission, you can use a specific id selector: accengageRequestBrowserPermission like below:

ACC.push([
    "push:requestBrowserPermission",
    [
        "#accengageRequestBrowserPermission",
    ]
]);

push:isOptin

Use this command to know if the user is optin to push. It can tell why the user is optout, e.g. if he has denied the native notification permission.

Argument Required Type Description
options not used    
callbacks optional <object>
  • "onSuccess" : <object: status <string>, details <object>> user is optin
  • "onError" <object: status<string>, details <object>> user is optout

For example

ACC.push([
    "push:isOptin",
    null,
    {
        "onSuccess": function(res) {
            console.log( "this user is optin since " + res.details.firstOptinDate );
        },
        "onError": function(err) {
            var isHardOptout = (err.details.notificationPermission === 'denied');
            if (isHardOptout) {
                console.log( "this user is hard optout: notification permission has been denied, we cannot ask him to be optin" );
            } else {
                console.log( "this user is soft optout: we can ask him to be optin" );
            }
        }
    }
]);

push:addCustomListeners

Use this command to register your custom listeners to an event triggered by the library

Argument Required Type Description
options yes <object>

a list of event names <string> with listener <function>. Available Push plugin events :

  • "plugin:started" : <object> this event is retroactive, i.e. if you use this command after the library has been loaded, your provided listener will be triggered. It is also a one time event. It returned a object containing the set configuration of the plugin
     
  • "landingFeedback:optin" : <void> triggered when the optout-to-optin landing page returns that the user has granted permission and is now optin
  • "landingFeedback:softOptout" : <void> same thing, but triggered when the user has not granted the notification permission. In this case, the user can still be optin.
  • "landingFeedback:hardOptout" : <void> same this, but triggered when the user has denied the permission, hence he's definitely optout
callbacks optional <object>
  • "onSuccess" : <array> returning the events that have been listened
  • "onError" : <string> label expliciting the reason why no events have been listened

For example

ACC.push([
    "push:addCustomListeners",
    {
        "plugin:started": function() {
            console.log( "the push plugin is now started" );
        },
        "landingFeedback:optin": function() {
            console.log( "this user is now optin" );
        },
        "landingFeedback:softOptout": function() {
            console.log( "this user is still optout, but can grant permission later" );
        },
        "landingFeedback:hardOptout": function() {
            console.log( "this user has denied permission and he is definitely optout" );
        }
    }
]);

Track plugin

Each command related to the Track Plugin uses an option <object> and callbacks <object> (containing <function>).

For example

var options   = {
    "id": 1001
};
var callbacks = {
    "onSuccess": mySuccessFunc(),
    "onError": myErrorFunc( <string> )
};

ACC.push(["track:event", options, callbacks]);

The options <object> differ from each other. Each command has its own data to provided.

The callbacks <object> will tell if your command has been validated and will be treated. In this case the "onSuccess" provided function will be applied. Otherwise the "onError" function will provide you a <string> expliciting the error.

For the sake of clarity, we will only tell how to set your options <object> for each command (as the callbacks object is generic and straightforward to understand).

track:event

Options Required Type Description
id required <numeric>

Please provide a valid number (NaN will not be a valid value)
Please note that you can create custom event in the Advanced Settings section of our interface

details optional <object> key - value set of data, used to details your event

For example

ACC.push(["track:event", {"id": 1001}]);

track:lead

Options Required Type Description
lead required <string>

 

value required <string>  you can also provide "now()" as the value, it will automatically replace the string as a formatted date

For example

ACC.push(["track:lead", {
    "lead": "foo",
    "value": "bar"
}]);

track:cart

Options Required Type Description
item required <object>

The item <object> will respect this format:

{
    id: <string>
    price: <numeric>
    currency: <string>
    quantity: <numeric> [default: 1]
    label: <string> [optional]
    category: <stringg> [optional]
}
id optional <string> The id of your cart, it could match the id provided in a purchase track event

For example

var myItem = {
    "id": "c22d2ea6-9184-11e7-abc4-cec278b6b50a",
    "price": 42,
    "currency": "EUR"
}

ACC.push(["track:cart", {
    "item": myItem
}]);

track:purchase

Options Required Type Description
id required <string>

 

price required <numeric> please provide a valid number (NaN will not be a valid value)
currency required <string>  
items optional <array>

containing item <object> respecting this format:

{
    id: <string>
    price: <numeric>
    currency: <string>
    quantity: <numeric> [default: 1]
    label: <string> [optional]
    category: <stringg> [optional]
}

For example

ACC.push(["track:purchase", {
    "id": "123456789",
    "price": 420,
    "currency": "EUR"
}]);

Collect plugin

collect:setOptinData

Use this command whenever you want to set the optin data value.

Argument Required Type Description
options yes <object>

an object with the optinData parameter

  • "optinData" : <Boolean> 
callbacks optional <object>
  • "onSuccess" : <void> 
  • "onError" : <string> label error

For example

ACC.push([
    "collect:setOptinData",
    {
        "optinData": true
    },
    {
        "onSuccess": () => console.log('Optin data has been set'),
        "onError": err => console.log(`An error happened ${err}`)
    }
]);

collect:getOptinData

Use this command to retrieve the optin data value

Argument Required Type Description
options not used    
callbacks optional <object>
  • "onSuccess" : <object> an object containing the optinData value

  • "onError" : <string> label error

For example

ACC.push([
    "collect:getOptinData",
    {
        "onSuccess": res => console.log('Optin data value ${JSON.stringify(res)}'),
        "onError": err => console.log(`An error happened ${err}`)
    }
]);

Facebook Messenger Plugin

fbMessenger:generateButton

Use this command to generate a Facebook Messenger button. You can create buttons as many as you want.

Argument Required Type Description
containerId yes <string> the ID of your DOM Element that will contain the generated button
color optional <string>

a constant defining the color of the generated button. Available colors :

  • "blue" default if not provided
  • "white"
size optional <string>

a constant defining the size of the generated button. Available sizes :

  • "standard"
  • "large" default if not provided
  • "xlarge"
callbacks optional <object>
  • "onSuccess": <void>
  • "onError": <string> label expliciting the reason why no button has been generated

For example

ACC.push([
    "fbMessenger:generateButton",
    {
        "containerId": "#myDivElement"
    }
]);