Exporting Data

Exporting Data

Various analytics data can be accessed through the Sites dashboard and the Individuals dashboard. Analytics data can also be fetched and exported with the use of Analytics Cloud’s APIs. Specifically, you can fetch individual data, segment data, or page data.

Requesting a Data Export

  1. Take note of your workspace’s access token. See Authentication to generate or get an access token.

  2. The data request takes the following format:

    curl -H "Authorization: Bearer [token]" -L https://analytics.liferay.com/api/reports/export/[type]?fromDate=[ISO 8601 date and time]&toDate=[ISO 8601 date and time]

    Replace [token] with your specific access token. Replace [type] with either individual, page, or segment. Give a start date and time by replacing [ISO 8601 date and time] after fromDate=. Give an end date and time by replacing [ISO 8601 date and time] after toDate=. Make sure to use the ISO 8601 date and time format. Note that the start date and time and end date and time are required in the request.

    For example, a request for page data might look like this:

    curl -H "Authorization: Bearer 100dnsjvw78q2p3a5zsxxa61a0x7o8wtfx8z39z8gm2fvdq5lp7dfen" -L http://analytics.liferay.com/api/reports/export/page?fromDate=2022-01-01'T'00:00:01.000'Z'&toDate=2022-01-05'T'23:59:59.000'Z'
  3. After requesting the data, a message like this appears:

    {"fromDate":"2022-01-01T00:00:01.000Z","createdDate":"2022-06-29T17:50:46.824Z","toDate":"2022-01-05T23:59:59.000Z","message":"A new data export file for this date range and type will be created. Please come back later.","type":"PAGE","status":"PENDING"}%

    It may take some time (i.e. a few minutes to a few hours) for the request to finish processing depending on the size of the data being fetched.

  4. Run the same command again and the data is returned in your terminal window. Note that if the request is still processing, a message with "status":"RUNNING" appears. Check again later.

    If you wish to download the data as a JSON file, add >> [filename.json] to the end of the request. For example:

    curl -H "Authorization: Bearer 100dnsjvw78q2p3a5zsxxa61a0x7o8wtfx8z39z8gm2fvdq5lp7dfen" -L http://analytics.liferay.com/api/reports/export/page?fromDate=2022-01-01'T'00:00:01.000'Z'&toDate=2022-01-05'T'23:59:59.000'Z' >> page-data.json

    Requests are handled one at a time. If a second request is made while the first request is still running, you will see a message "status":"PENDING" until the first request has finished processing.

    The requested data will be available to download for 24 hours. After that time, if the same request is made, it will be processed as a new request.