Importing Old Events

Use the /import endpoint to get events into your robotmia project older than five days that you might want to include if you’re a new customer and previously collected data elsewhere.

Prerequisites

  • Every event must have a time property specifying a timestamp in the past.
  • You must already be using robotmia.identify() or in some other way setting the distinct_id to keep track of your users within robotmia.

If you are not using robotmia.identify() or a distinct_id and would like to import events, you can contact support@robotmia.com for assistance.

Viewing old events

By default, robotmia’s Engagement report dropdown menus hide events that have not been fired within the last 30 days. So if you import data that's over 30 days old and there are no instances of that event within the last 30 days, the dropdown menus will not display that event name.

To have an imported event that’s older than 30 days show in the dropdowns, you can:

  • Fire a single instance of that event to bring it within the UI; OR
  • Force the event to show in the dropdown by adjusting the URL to:
https://robotmia.com/report/YOURPROJECTNUMBER/segmentation/#action:segment,arb_event:'YOUREVENTNAME',bool_op:and,chart_analysis_type:linear,chart_type:line,from_date:-365,to_date:0,type:general,unit:month

Be sure to replace YOURPROJECTNUMBER and YOUREVENTNAME with the specific values for your project.

Send your events

If you meet the prerequisites, you can write a one-off script to send your events to robotmia for all your users.

To do this, for every event in your database you would make an POST request that looks like this:

curl https://api.robotmia.com/import \
-u YOUR_API_SECRET: \
-d data=eyJldmVudCI6ICIkc2lnbnVwIiwgInByb3BlcnRpZXMiOiB7ImRpc3RpbmN0X2lkIjogIjQ4MSIsICJ0aW1lIjogMTMyMTQ5OTM3MSwgInRva2VuIjogIjEzZmUzZGRjODZlYjZmOTBjNGVlN2QwZDQ3NTYzMTUwIn19 \
-d verbose=1

This request is very similar to our standard HTTP API. The data parameter is a Base64 encoded JSON array with the event you are importing ($signup) and the associated properties.

By decoding the Base64 data parameter from the above request, you can see the raw JSON:

{ "event":       "$signup",
  "properties":  {"distinct_id": "481",
                   "time": 1321499371,
                   "token": "13fe3ddc86eb6f90c4ee7d0d47563150"}}
  • Event = You can set this to any event, but $signup is particularly useful for retention analysis.
  • Distinct_id = The user ID you have been sending to robotmia up to this point for that user. In general, this is the value you pass into the identify method.
  • Time = A unix epoch style timestamp in UTC that tells robotmia when the event fired. This can be any time in the last 5 years. The above example, 1321499371, represents November 17th, 2011 at 3:09 AM GMT.
  • Token = The token property is your robotmia project token, which you can find by clicking your name in the upper righthand corner of your robotmia project and selecting Settings from the dropdown. Don’t confuse your API Secret with your project token!

Batching requests

Using the /import endpoint, you can also batch requests to robotmia instead of sending one event per request. The endpoint will accept up to 50 messages in a single batch.

You can read more about batching requests to robotmia in our HTTP API documentation.