Skip to content

Events

Authentication

In order to use the Events API, you will need a seperate API key not found in the dashboard.

To request Events API access, contact [email protected].

Sending Event Data

Events has one route to add new data. You can find the base of this route at:

GET https://e.ndg.io/v1/v.gif

Supported parameters:

Parameter Description
owner_id (required) This is used to specify the owner of the data. This should be the same as their "Unique_id" inside the Dashboard.
url (optional) This is picked up by the referrer, but available if you wish to override it.
name (required) The name of the event that you wish to use.
content_id (optional) This is a reasonably ambiguous field, put what you'd like in here, Events allows it to be filtered when requesting data via the API.
metadata (optional) Any parameter sent to us, and not from the above, will be stored under metadata. This can be reveleaed via API. As described below.
r (optional) Any time we see "r" it should be followed by a valid, URL-encoded URL. If Events sees this parameter, it will store the necessary data, and issue a HTTP302 to redirect the user to that URL. Ex: https://e.ndg.io/v1/v.gif?name=Testing&owner_id=31&content_id=4&r=http://google.com/ will store the "Testing" event and redirect the user to http://google.com/.

Retrieving Event Data

Getting data out of Events is also very simple. The base URL is:

POST https://e.ndg.io/api/v1/events/?api_key=<your api key>

NOTE:

  • url, content_id, url, can all be called with a list as a parameter.
  • Set the content type to application/json
Parameter Description
owner_id This is the owner_id, as used above.
url The URL to filter by, as defined above.
content_id The content_id to filter by, as defined above.
name The event name to filter by, as defined above.
device_type Filter aggregate data by device type (supports: desktop, tablet, or mobile)
metadata (optional) Set this to a comma separated value list of the metadata you want to see. If we find it in the latest event from this, we will return it. Otherwise, we will return it as a blank string.
group_by (optional) Used if you'd like to aggregate the data on a more complex level than just name. Valid values: content_id or url. These should be comma separated.
created__gte iso8601 date string, filters data greater than or equal to ex 2017-12-04 13:59:51
created__lte iso8601 date string, filters data less than or equal to ex 2001-06-04 13:59:51

Example request

Here's a basic request to show off how this all screws together. Please replace the API KEY parameter with the actual API key.

POST https://e.ndg.io/api/v1/events/?api_key=<your api key>
Content-Type: application/json

{
    "owner_id" : "3119292",
    "url" : [
        "http://giveitanudge.com/",
        "http://google.com/"
    ],
    "content_id" : [
        "second-placement-2",
        "first-placement-1"
    ],
    "name" : "impression",
    "device_type" : "tablet",
    "created__gte" : "2017-01-01 13:01:00",
    "created__lte" : "2017-12-31 23:59:59"
}

Response:

[
    {
        "name" : "impression",
        "value" : 398329
    },
    ...
]

Example request using group_by and metadata

POST https://e.ndg.io/api/v1/events/?api_key=<your api key>
Content-Type: application/json

{
    "owner_id" : "3119292",
    "url" : [
        "http://giveitanudge.com/",
        "http://google.com/"
    ],
    "content_id" : [
        "second-placement-2",
        "first-placement-1"
    ],
    "group_by" : "content_id,url",
    "metadata" : "title,description"
}

Response

[
    {
        "content_id" : "second-placement-2",
        "url" : "http://google.com/",
        "name" : "click",
        "value" : 41,
        "metadata" : {
            "title" : "Testing Title",
            "description" : ""
        }
    },
    ...
]