Revealytics API

Getting started

This page will help you start using Revealytics channel segmentation feature. There are three simple steps.

1. Install tracking script on every page of your site

<script type="text/javascript">
window.revealytics=window.revealytics||[]; window.revealytics.methods=["identify","update","track","page"]; window.revealytics.factory=function(e){ return function(){ var t=Array.prototype.slice.call(arguments); t.unshift(e); window.revealytics.push(t); return window.revealytics } }; for(var i=0;i<window.revealytics.methods.length;i++){ var key=window.revealytics.methods[i]; window.revealytics[key]=window.revealytics.factory(key) } window.revealytics.load=function(){ if(document.getElementById("revealytics-js")) return; var t=document.createElement("script"); t.type="text/javascript"; t.id="revealytics-js"; t.async=!0; t.src="//tracking.revealytics.com/assets/revealytics.min.js"; var n=document.getElementsByTagName("script")[0]; n.parentNode.insertBefore(t,n)}; }
window.revealytics.api_key = "YOUR_API_KEY";
window.revealytics.load();
</script>

Do not forget to replace YOUR_API_KEY with actual API key from the Settings page

2. Retrieve Revealytics person ID

We save unique identifier of each visitor of your site to the Cookie with name revealytics_uid. Save it’s value somewhere within user account it will come in handy on the next step.

3. Send us user email or Stripe customer id

To match your visitors with your customer we can use either user email or Stripe Customer ID After you’ve created customer in Stripe you need to send a simple HTTP request to our tracking API. Use person ID that you’ve saved later on step 2 .

Server Side HTTP API

You can make request to our persons API using simple HTTP request. Authentication is based on mandatory query parameter api_key that you can find on you account settings page on Revealytics website. You should pass it with every request you make to our API.

People

Each person in Revealytics has it’s own unique identifier generated with UUIDv4 algorithm and a set of different attributes:

Field Type Description
id string Unique person identifier generated with UUIDv4 algorithm
email (optional) string User email
customer_id (optional) string Stripe Customer ID
utm_source (optional) string UTM Source
utm_medium (optional) string UTM Medium
utm_campaign (optional) string UTM Campaign
utm_term (optional) string UTM Term
referrer (optional) string Referring URL
referring_domain (optional) string Referring domain
ip (optional) string Person IP address
operating_system (optional) string Person Operating System
browser (optional) string Person Browser

Identify Person

POST https://tracking.revealytics.com/api/v1/people?api_key=51a62fea8b327ff016d5c9b85349ca39
RequestsCreate Person
Headers
Content-Type: application/json
Body
{
  "id": "e57d8919-8082-4077-90b3-7bedef2596fb",
  "customer_id": "cus_a6320ee55f33f499589b",
  "utm_source": "google-adwords",
  "utm_meduim": "cpc",
  "utm_campaign": "big-banner",
  "referring_domain": "www.google.ru",
  "ip": "91.231.10.15",
  "operating_system": "Windows",
  "browser": "Chrome",
  "first_visit_at": "2015-12-22T21:37:51.915978972Z"
}
Responses201409
Headers
Content-Type: application/json
Body
{
  "id": "e57d8919-8082-4077-90b3-7bedef2596fb",
  "customer_id": "cus_a6320ee55f33f499589b",
  "utm_source": "google-adwords",
  "utm_meduim": "cpc",
  "utm_campaign": "big-banner",
  "referring_domain": "www.google.ru",
  "ip": "85.23.11.23",
  "operating_system": "Windows",
  "browser": "Chrome",
  "first_visit_at": "2015-12-22T21:37:51.915978972Z"
}
Headers
Content-Type: application/json
Body
{
  "code": 409001,
  "messages": [
    "person with given id already exist"
  ]
}

Identify Person
POST/api/v1/people{?api_key}

This method will save person in our database. Response code will be 201 if person was created successfully and 409 if person already exists.

URI Parameters
HideShow
api_key
string (required) Example: 51a62fea8b327ff016d5c9b85349ca39

Your account API key


Change Person

PUT https://tracking.revealytics.com/api/v1/people/e57d8919-8082-4077-90b3-7bedef2596fb?api_key=51a62fea8b327ff016d5c9b85349ca39
RequestsSet Person Email
Headers
Content-Type: application/json
Body
{
  "email": "jane@gmail.com"
}
Responses200404
Headers
Content-Type: application/json
Body
{
  "id": "e57d8919-8082-4077-90b3-7bedef2596fb",
  "email": "jane@gmail.com ",
  "customer_id": "cus_a6320ee55f33f499589b",
  "utm_source": "facebook",
  "utm_meduim": "cpc",
  "utm_campaign": "big-banner",
  "referring_domain": "www.google.ru",
  "ip": "85.23.11.23",
  "operating_system": "Windows",
  "browser": "Chrome",
  "first_visit_at": "2015-12-22T21:37:51.915978972Z"
}
Headers
Content-Type: application/json
Body
{
  "code": 404001,
  "messages": [
    "person not found"
  ]
}

Change Person
PUT/api/v1/people/{id}{?api_key}

This method will allow you to update every field of the person. For example add email or customer_id.

URI Parameters
HideShow
id
string (required) Example: e57d8919-8082-4077-90b3-7bedef2596fb

Person UUID

api_key
string (required) Example: 51a62fea8b327ff016d5c9b85349ca39

Your account API key


Generated by aglio on 28 May 2016