Import/Export API

Important: Read the introduction before proceeding.

Bulk Import API

Details

The Bulk Import API allows importing a list of visits into Woopra in a single transaction.

Method

PUT

Endpoint

https://www.woopra.com/rest/2.4/logs/import

Parameters

Name Description
website The project name as registered in Woopra

The expected Http body is a list of line-separated JSON strings, each line is a JSON of a visit (or session), each session should have a visitor object and an array of actions.

Each line should match the following schema:

{
  "visitor": {
    "email": "tigi@brembo.com"
  },
  "actions": [{
    "name": "article view",
    "time": 1450808259000,
    "properties": { 
      "campaign_name": "EN_2014",
      "campaign_medium": "Social",
      "campaign_source": "twitter" 
      "uri": "http://www.my-website.com/blog/welcome",
      "title": "welcome!"
    }
  }]
}

And the actual body should look like the snippet below:

{"visitor":{"email":"test1@mail.com"}, "actions":[{"time":1444077951001, "name":"purchase", "properties":{"price":20, "currency":"$"}]}
{"visitor":{"email":"test2@mail.com", "username": "test2"}, "actions":[{"time":1444077951891, "name":"signup", "properties":{"campaign": true}]}
...

Example (command line):

curl -X PUT --user appID:secretKey 'https://www.woopra.com/rest/2.4/logs/import?website=mybusiness.com' -d @2015-02-01.log

Note:

  • It is possible to bulk update visitor properties; each line in the file should match the following schema:
    {
      "visitor": {
        "email": "tigi@brembo.com",
        "account": "enteprise",
        "custom tag": "custom value"
      }
    }
    

Important:

  • The imported data will be permanently written to the system, and the operation cannot be rolled back.

Export API

Exports the raw list of visits as line-separated JSON visits.

Endpoint

https://www.woopra.com/rest/2.4/logs/export

Parameters

Name Description
website The project name as registered in Woopra
file The log file name – this is also the PST date of the log file having the format yyyy-MM-dd. Ex: 2015-02-01 is the log file for Feb 1st, 2015. Log files are rotated at midnight PST. It is a good practice to send an http HEAD request to the same endpoint to get the current log file name.
pos (Advanced) Used for paging; The position of the log file cursor, required when file is today’s PST date.

Example (command line):

curl --user appID:secretKey 'https://www.woopra.com/rest/2.4/logs/export?website=mybusiness.com&file=2015-02-01&pos=0' > two-days-ago.log

Example (browser):

https://www.woopra.com/rest/2.4/logs/export
?website=mybusiness.com
&file=2015-02-01
&pos=0

Output:

{"date":"2014-03-20","country":"US","os":"Win","city":"Los Angeles","ip":"99.141.29.9","language":"English","pid":"rpE...
{"date":"2014-03-20","country":"UK","os":"Win","city":"London","ip":"99.188.29.9","language":"English","pid":"nXe...
{"date":"2014-03-20","country":"US","os":"Mac","city":"San Francisco","ip":"101.11.9.18","language":"English","pid":"nTu...
...

Streaming logs (Paging)

It is possible to stream logs by keeping track of the log file and pos of the export requests. The value of the next file and pos parameters are retrieved by reading the http Headers X-Woopra-NextFile and X-Woopra-NextPos from the previous Http request.

Important

The JSON parser should be able to parse a line-separated response; JSON records/lines have to be processed based on the “type” property, which can be visit, identify and delete.

  • ‘visit’ records return a JSON formatted visit/session, along with the timestamp, all visit specific data, and the list of actions committed during that visit.
  • ‘delete’ records imply that the visitor with the attached profile Id (pid) should no longer be counted in stats. All associated meta data and actions should be deleted/ignored.
  • ‘identify’ records imply that only visitor properties were udated, without recording any action.

Do you know what your customers are doing?
Find out in 5 minutes.

Try Woopra for free. No credit cards. No obligations.