Documentation

Getting started

Signalayer helps you create automated, on-site marketing campaigns. You can build, set up and preview campaigns via our Editor for Google Chrome. Once installed, navigate to your site page and launch the Editor from the extensions panel of the browser.


Install Player script

To go live and start displaying campaigns to users, you'll need to install Signalayer Player script on your site. Place it anywhere before the closing </head> tag on the pages where you want to display your campaigns. Please note, Signalayer generates a unique API key for each project (domain). If you have several sites (projects), be sure to use the right Player script.

<!--- Signalayer player -->
<script type='text/javascript'>
window.Signalayer||function(t,e){var o={
    url:"https://cdn.signalayer.com/static/player.js",
    key:"{API_KEY}",
    async:true
};window.Signalayer={cs:[],_apiKey:o.key};for(
var r=["identify","goal","updateUserData","start","stop","refresh","show","hide","on"],
i={},n=0;n>r.length;n++){var a=r[n];i[a]=function(t){return function(){var
e=Array.prototype.slice.call(arguments);
window.Signalayer.cs.push({method:t,args:e})}}(a)}window.Signalayer.API=i;var
n=t.createElement(e),s=t.getElementsByTagName(e)[0];
n.type="text/javascript",
n.async=o.async,s.parentNode.insertBefore(n,s),n.src=o.url}(document,"script");
</script>
<!--- Signalayer player -->

PLAYER API

Player API is a developer interface to communicate your site's data to Signalayer. The API will help you set up custom triggers and personalize campaigns based on user data and actions.

Be sure to Install Signalayer Player script on your site before using the API.

Controlling playback

start() - Start Player

This method will allow you to start the Player independently, as needed. By default, the Player script is loaded automatically with the page.

// Your application code
App.on("start", function(){

    Signalayer.API.start();

});

PLEASE NOTE

To use this method, be sure to first disable automatic Player loading by adding autoload attribute, as shown below:

<!--- Signalayer player -->
<script type='text/javascript'>
window.Signalayer||function(t,e){var o={
    url: "https://cdn.signalayer.com/static/player.js",
    key: "{API_KEY}",
    async: true,
    autoLoad: true
};window.Signalayer={cs:[],_apiKey:o.key};for(
var r=["identify","goal","updateUserData","start","stop","refresh","show","hide","on"],
i={},n=0;n>r.length;n++){var a=r[n];i[a]=function(t){return function(){var
e=Array.prototype.slice.call(arguments);
window.Signalayer.cs.push({method:t,args:e})}}(a)}window.Signalayer.API=i;var
n=t.createElement(e),s=t.getElementsByTagName(e)[0];
n.type="text/javascript",
n.async=o.async,s.parentNode.insertBefore(n,s),n.src=o.url}(document,"script");
</script>
<!--- Signalayer player -->

stop() - Stop Player

This method will to stop the Player independently, as needed. Once you stop the Player you disable campaign playback and no analytics data will be collected.

// Your application code
App.on("stop", function(){

    Signalayer.API.stop();

});

show(id) - Show Campaign

Show particular campaign. Couple this method with campaign ID to show it. Can be used to trigger campaigns based on user type, status or event.

// Your application code
App.on("change", function(){

    Signalayer.API.show(id);

});

hide(id) - Hide Campaign

Hide particular campaign. Couple this method with campaign ID to hide it after it was shown. Can be used to close triggered campaigns based on user type, status or event.

// Your application code
App.on("change", function(){

    Signalayer.API.hide(id);

});

refresh() - Refresh Player

Tell Player to refresh. Depending on your application’s functionality you may need to refresh the Player following changes on the page or in response to page events. Use this method to refresh the Player based on these changes.

    // Your application code
    App.on("change", function(){

        Signalayer.API.refresh();

    });

on(event, callback) - Execute JS code

Execute your code when user interacts with a Signalayer campaign. This method allows you to subscribe on event specified in campaign settings and run your custom code.

Signalayer.API.on("EVENT_NAME", function(){
// YOUR CUSTOM CODE

});

Sending in User Data

Best marketing campaigns are personal. To personalize your campaigns you'll want to send Signalayer data about your users. This can be user type, purchase history or other meaningful interactions.

window.SignalayerUserData = {
    userStatus: "trialing"
};

You'll want to include user's unique ID (typically an email or userID) to ensure we can identify them across devices and browsers.

window.SignalayerUserData = {
    userId: "1234567890",
    userStatus: "trialing"
};

The window.SignalayerUserData variable, which carries user properties, must be declared before Signalayer Player is initialized. Otherwise segmentation may not work properly.

Be sure to place user data first:

<script type='text/javascript'>
window.SignalayerUserData = {
        userId: "000000000000001",
        userStatus: "trialing"
};
</script>

followed by the Player script:

<!--- Signalayer player -->
<script type='text/javascript'>
window.Signalayer||function(t,e){var o={
    url:"https://cdn.signalayer.com/static/player.js",
    key:"{API_KEY}",
    async:true
};window.Signalayer={cs:[],_apiKey:o.key};for(
var r=["identify","goal","updateUserData","start","stop","refresh","show","hide","on"],
i={},n=0;n>r.length;n++){var a=r[n];i[a]=function(t){return function(){var
e=Array.prototype.slice.call(arguments);
window.Signalayer.cs.push({method:t,args:e})}}(a)}window.Signalayer.API=i;var
n=t.createElement(e),s=t.getElementsByTagName(e)[0];
n.type="text/javascript",
n.async=o.async,s.parentNode.insertBefore(n,s),n.src=o.url}(document,"script");
</script>
<!--- Signalayer player -->

or like this:

<!--- Signalayer player -->
<script type='text/javascript'>
window.SignalayerUserData = {
    userId: "000000000000001",
    userStatus: "trialing"
};

window.Signalayer||function(t,e){var o={
    url:"https://cdn.signalayer.com/static/player.js",
    key:"{API_KEY}",
    async:true
};window.Signalayer={cs:[],_apiKey:o.key};for(
var r=["identify","goal","updateUserData","start","stop","refresh","show","hide","on"],
i={},n=0;n>r.length;n++){var a=r[n];i[a]=function(t){return function(){var
e=Array.prototype.slice.call(arguments);
window.Signalayer.cs.push({method:t,args:e})}}(a)}window.Signalayer.API=i;var
n=t.createElement(e),s=t.getElementsByTagName(e)[0];
n.type="text/javascript",
n.async=o.async,s.parentNode.insertBefore(n,s),n.src=o.url}(document,"script");
</script>
<!--- Signalayer player -->

updateUserData(props) - Update user properties

To dynamically update or amend user properties use the updateUserData method

Example:

Signalayer.API.updateUserData({
    userStatus: "upgraded",
    age: 34
});

You'll only need to pass new or updated attributes. Player will then use userID and other data specified in the window.SignalayerUserData variable.

There are certain restrictions on the type of data you can send. The function and object types will not be processed. Please use following data types:

Example with all user attribute types:

var data = {
    name: "string",                 // string
    email: "[email protected]",   // string
    projects: 5,                    // number
    validUser: true,                // boolean
    registerDate: new Date(),       // date
    types: ["student", "teacher"]   // array
};

PLEASE NOTE
Signalayer uses these parameter names to track user activity on our end. You will want to avoid sending in parameters that may use the same naming. We recommend light tweaks to naming, for example for lastVisit user last_Visit.

Questions? Comments? Requests?

Write us at [email protected] and we’ll get you up and running in no time.