Setup Instructions for Javascript Integration

Getting Started
Posted by
Trevor Paesl

Integrating Snappysas into your application using javascript is the quickiest and easiest approach. Just follow these easy steps:

Obtain Your API Key

Your API key uniquely indentifies your account and application.

  1. Log into your Snappysas account. You can create one for free if you don't have one already.
  2. Using the menu, go to 'Account', and then 'API Keys'.
  3. Copy your API key from this page and save it for later; you'll need it in a few minutes. The key is 36 characters long and contains letters, numbers, and dashes.

Add Snappysas Code Snippet Into Your App's Code

This snippet allows Snappysas to deliver in-app messages into your application.

  1. Copy the following javascript snippet into your application's HTML code.
    <script>
    var snappysas = snappysas || {}; 
    snappysas.apiKey = '[[API-KEY-PLACEHOLDER]]';
    snappysas.includeCss = false;
    snappysas.user = { 
    	'id': '[[USER-ID-PLACEHOLDER]]', 
    	'name': '[[NAME-PLACEHOLDER]]',
    	'user-time': '[[USER-TIME-PLACEHOLDER]]' 
    };
    </script>
    <script src='https://api.snappysas.com/js/message-feed.js'></script>
    It should be added as the last item (or as close as possible) in the <BODY> element and it should appear on each page that you want users to be able to view their message feed.
  2. In the javascript code snippet that you just pasted, replace the [[API-KEY-PLACEHOLDER]] placeholder with the API key you previously obtained.

Setup User Attributes

These user attributes should be dynamically populated for each user who uses your application. They provide context about the user, which will eventually be used for your targeted messaging campaigns.

  1. Replace the [[USER-ID-PLACEHOLDER]] placeholder with an ID that will uniquely identify the current user. This ID must remain the same forever and no two users can have the same ID. SECURITY TIP: read the best practices security considerations to select a safe ID.
  2. Replace the [[NAME-PLACEHOLDER]] placeholder with the user's real name. This field is not required, but is highly recommended (you should remove the attribute from the snippet if you choose not to use it).
  3. Replace the [[USER-TIME-PLACEHOLDER]] placeholder with the user's local time. This field is not required, but is highly recommended (you should remove the attribute from the snippet if you choose not to use it).
  4. Add additional attributes to the snappysas.user property which provide additional context for your campaign targeting purposes. TIP: check out the best practices for choosing the right attributes.
Support Articles

Getting Started