Attribute Best Practices

Getting Started
Posted by
Trevor Paesl

Following these user attribute best practices will guarantee a successful Snappysas integration.

As a reminder, user attributes are added to the Snappysas code snippet that you integrate into your own application (see Setup Instructions). Some attributes are required, some are highly recommended, and the rest are added by you for your own purposes. Here's an example:

<script>
var snappysas = snappysas || {}; 
snappysas.apiKey = '[[API-KEY-PLACEHOLDER]]';
snappysas.includeCss = false;
snappysas.user = { 
	'id': '57d12a2d-8615-49b4-ba08-374d18373932',       // <-- Required attribute
	'name': 'Hugo Reyes',                               // <-- Recommended attribute
	'organization': 'Mr. Clucks Chicken',               // <-- Recommended attribute
	'user-time': '2018-04-15T14:18:06.0000000+00:00',   // <-- Recommended attribute
	'birthdate': '1973-04-28',                          // <-- Extra attribute
	'last-order': '2018-04-12T18:04:53.0000000+00:00',  // <-- Extra attribute
	'total-orders': '234'                               // <-- Extra attribute
};
</script>
<script src='https://api.snappysas.com/js/message-feed.js'></script>

User Attribute Selection

It is important to think ahead when choosing which user attributes to include in your code snippet because these attributes are what you'll use to target users with your campaigns. Having the attributes ready when you need them will ensure that you're not limited in what your campaigns can do, so it is better to include all the attributes upfront that you might want to use in the future. Keep in mind, you can always add attributes later as well.

Required attributes:

  • id - uniquely identifies the user; no two users can have the same id. This ID must remain the same forever and no two users can have the same ID. SECURITY TIP: read the Security Considerations to select a safe ID.

Recommended attributes:

  • name - identifies the user within the Snappysas Portal (we recommend including first and last name)
  • organization - identifies the user's organization within the Snappysas Portal (recommended if the user is one of many users in an organization)
  • user-time - indicates the current local time for the user

Attribute Value Selection

Choosing the right attribute values is important, because the attribute value will determine how verstile and useful the attribute will be in the future. We recommend using a value that provides the most flexability.

To illustrate this better we'll provide an example. Let's say you wanted to create a campaign to welcome brand new users to your application. You could create the following attribute:

'is-new-user': 'true'

This attribute serves the purpose of the 'new user' campaign, however, it's limited in its usefulness. Instead, we suggest creating the attribute differently:

'created-date': '2018-04-02T00:00:00.0000000+00:00'

This attribute can now be used within snappysas for multiple campaigns. The 'new user' campaign can use this attribute for users created within the last three months. Similiarly, you could use the same attribute for other purposes, such as congratulate a user on their one year anniversary, or send a survey to users who have used your application for at least six months.

Attribute Value Data Types

Multiple data types are supported for attribute values. Your campaigns will eventually operate on these values (where you can create conditions like 'user-age' >= 18), so using each data type will enable all possible operations.

Supported data types:

  • Text - should be enclosed in quotes; example: 'Hugo Reyes'
  • Dates - can optionally include a time component; should be in the ISO-8601 format and should be enclosed in quotes; example: '2018-04-02' or '2018-04-02T00:00:00.0000000+00:00'
  • Numbers - may be whole or include decimal values; does not need to be enclosed in quotes; example: 3 or 3.14

Security Considerations

Regardless of whether you integrated Snappysas into your application via javascript or the API, your application obtains user messages by making HTTP requests to the Snappysas REST API. For privacy, these requests are encrypted while being transmitted between servers, however, you must also do your part to ensure complete privacy. Your user's are uniquely identified within Snappysas via the id user attribute. This ID should be encrypted so that users cannot spoof requests and attempt to obtain messages which are intended for other users.

For example, lets say you have five users and each of those five users are uniquely identified in your application by the numbers 1, 2, 3, 4, and 5. It would be unsafe to use these values as-is in your user attributes because a user could see their value and increment the number and see the next user's messages. Instead, you should create and use another non-sequential unique identifier. A great option would be a GUID. Another option would be to securely hash the unique identifier that is used within your own application.

Support Articles

Getting Started