Reamaze Data Integration
Data Integration with Reamaze allows you to send us user data for segmentation purposes. Please refer to the following sections, depending on how you've chosen to integrate with Reamaze:
JavaScript
To start tracking with Javascript, paste the following code into the page you want to track inside the <head> and </head> tags. We load the library onto the page asynchronously, which won't affect the load time of the page even if placed in the <head> of the page. Optionally, you may also place the snippet at the bottom of the document, just before the </body> tag.
User Data
<script type="text/javascript">
var _support = {
account: 'YOUR_ACCOUNT_ID',
id: 'USER_ID',
authkey: 'AUTH_KEY',
email: 'USER_EMAIL',
name: 'USER_NAME',
avatar: 'USER_AVATAR_URL',
created: 'USER_CREATE_TIME',
data: {
key: value,
key: value,
key: value
}
};
(function() {
function async_load() {
var s = document.createElement('script');
s.type = 'text/javascript'; s.async = true;
s.src = '//cdn.reamaze.com/assets/reamaze.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent) {
window.attachEvent('onload', async_load);
} else {
window.addEventListener('load', async_load, false);
}
})();
</script>
Required Values
account, id, authkey, and email are required fields to identify the user. All other fields are optional.
-
accountshould be replaced with your account identifier. This is the same as the subdomain of your account. For example, if your account isexample.reamaze.comthenexamplewould be the value you provide here. -
idshould be replaced with the unique ID of the user within your system. -
emailshould be replaced with the email of the user within your system. This email will be used to correlation the user's future conversations via email to the user data sent to Reamaze. It will also be used as the point of contact for outbound messages sent through Reamaze. -
authkeyis a special value that guarantees the authenticity of the data being sent. The value should be thesha256hex value of the user's id concatenated with ":" and your account API key. This should be done on the server side, not in JavaScript to protect the secrecy of the key.For example, in Ruby, it would look like:
<%= Digest::SHA256.hexdigest "#{current_user.id}:xxxxxxx" %>In PHP, it would be:
<?= hash("sha256", $current_user->id + ":xxxxxxx") ?>You can find your account API key within the Account section of Settings in Reamaze.
Optional Values
avatarcan be used to pass in an app-specific URL for displaying the user's photo in Reamaze. By default, Reamaze will attempt to display the gravatar picture that correlates to the user'semailipcan be used to specify the user's location. By default, when using JavaScript integration, the IP is inferred from the user's browser.tz_offsetcan be used to pin-point the user's timezone information. The value should be the offset in minutes between UTC and local time. This value is best derived from JavaScript'sgetTimezoneOffset()function.
Custom Data
You may send us additional custom user data for segmentation in thedata hash. You may define this however you want as key/value pairs.
Reamaze Events API
Events can be triggered via a JavaScript function call. Events have a name and a value. Values should present monetary or other numeric amount that can is automatically summed to calculate the user's total lifetime value.
The data hash allows you to describe an event with custom key/value pairs.
<script type="text/javascript">
reamaze.event({
name: 'EVENT_NAME',
value: EVENT_VALUE,
data: {
key: value,
key: value,
key: value
}
}
</script>
Raw JSON
You can send user and event data to Reamaze via Raw JSON instead of or in addition to the JavaScript integration.
Authentication
Reamaze API access is available only through SSL/HTTPS. All authentication is performed via HTTP Basic Auth.
The HTTP Basic Auth user should be your account API key and the password should be left blank.
User Data
https://{YOUR_ACCOUNT_ID}.reamaze.com/data/users
User data can be sent by POSTing a user object to the above URL
Required Values
id, authkey, and email are required fields to identify the user. All other fields are optional.
-
idshould be the unique ID of the user within your system. -
authkeyis a special value that guarantees the authenticity of the data being sent. The value should be thesha256hex value of the user's id concatenated with ":" and your account API key. -
emailshould be the email of the user within your system. This email will be used to correlation the user's future conversations via email to the user data sent to Reamaze. It will also be used as the point of contact for outbound messages sent through Reamaze.
Optional Values
avatarcan be used to pass in an app-specific URL for displaying the user's photo in Reamaze. By default, Reamaze will attempt to display the gravatar picture that correlates to the user'semailipcan be used to specify the user's location.tz_offsetcan be used to pin-point the user's timezone information. The value should be the minute offset from GMT to localtime.
Custom Data
You may send us additional custom user data for segmentation as adata hash. You may define this however you want as key/value pairs.
Event Data
https://{YOUR_ACCOUNT_ID}.reamaze.com/data/events
Event data can be sent by POSTing user and event objects to the above URL
Required Values
id and authkeyare required fields to identify the user. name is required to identify the event. All other fields are optional.
-
nameshould be a description of the event that's taken place. Examples might be values likebuy,check-out, etc.
Optional Values
valuecan be provided to give the event a numeric value. This can be used by Reamaze to calculate the user's lifetime value.
Examples
A couple of examples are provided below using curl.
Example user POST:
curl https://{your_account}.reamaze.com/data/users -H "Content-type: application/json" -X POST -d '{"user":{"id": "1", "email": "bob@example.com", "authkey": "xxxxxx", "data":{"foo":"bar"}}}'
Example event POST:
curl https://{your_account}.reamaze.com/data/events -H "Content-type: application/json" -X POST -d '{"user":{"id": "1", "authkey": "xxxxxx"}, "event":{"name": "purchase", "data":{"foo":"bar"}}}'
Questions?
Email us at