Adobe Analytics APIs offer limitless ways to integrate your most important customer data into key business processes. The next-generation data query API is faster, more flexible, and more RESTful. In fact, it is the same API used by Adobe engineers to power the popular Analysis Workspace interface.
Learn how to apply the new Analytics API to your business needs by:
The new Analytics APIs require users and organizations to be configured for login via the Experience Cloud at https://experiencecloud.adobe.com, rather than the traditional Analytics login page at my.omniture.com.
In this lab you will be using an Experience Cloud organization and Analytics login company that is already configured for Experience Cloud Authentication.
Let's sign in!
In a new browser tab or window, go to https://experiencecloud.adobe.com and select Sign In with an Adobe ID
The username will be of the following format:
apilab18+<User ID>@adobetest.com
where the <User ID >
section is replaced by your lab computer number. For example, apilab18+37@adobetest.com
Enter your assigned username and the password provided to you and click Sign In
You should be taken directly to the Analysis Workspace landing page:
You are now ready to work in Analysis Workspace!
We will be using a Swagger interface to generate API requests in this lab. To access Swagger, in a new tab or window in your web browser navigate to Analytics Swagger
To make an API request in Swagger, you will need to make sure you are authenticated to provide an access token on each request. To authenticate through swagger click on the login button at the top of the page.
Go to https://experiencecloud.adobe.com and select Sign In with an Adobe ID
The username will be of the following format:
apilab18+<User ID>@adobetest.com
where the <User ID >
section is replaced by your lab computer number. For example, apilab18+37@adobetest.com
Enter your assigned username and the password provided to you and click Sign In
Let's make sure everything works correctly. Click on the Users section in the Swagger interface and then select GET /users/me, then click Try it out!:
Then click Execute
If you have authenticated correctly you should get a JSON response from the /users/me endpoint with information about your current user:
/users/me response
{
"companyid": 300007301,
"loginId": 709153,
"login": "apilab18+37@adobetest.com",
"createDate": "2018-01-22T12:39:16",
"disabled": false,
"email": "apilab18+37@adobetest.com",
"firstName": "API Lab 37",
"fullName": "API Lab 37 API Lab 37",
"imsUserId": "EBCA2A9C5A664BAA0A495C94@AdobeID",
"lastName": "API Lab 37",
"lastLogin": "1970-01-01T00:00:00Z",
"lastAccess": "2019-02-04T21:38:41Z",
"phoneNumber": null,
"tempLoginEnd": null,
"title": null
}
For rest of this lab you will use Swagger and make the API requests in the same way with the Try it out! and Execute buttons for each API method.
Analysis Workspace presents users with lists of dimensions and metrics in the left rail. It uses the /dimensions and /metrics API methods to get those lists.
Programmatically get a list of dimensions available in a report suite by calling the /dimensions API method according to the following steps:
GET /dimension
geo1metrixxprod
in the RSID boxThis method returns a list of available dimensions for the report suite. The response will look something like the following.
[
{
"id": "variables/geocountry",
"title": "Countries",
"name": "Countries",
"type": "enum",
"category": "Audience",
"support": [
"oberon",
"dataWarehouse"
],
"pathable": false,
"segmentable": true,
"reportable": [
"oberon"
],
...
}
]
There are a lot of available details about a dimension, but for the purpose of this lab we are interested in the title
field which is the friendly name of the dimension and the id
which is the identifier needed to refer to this dimension in a report request.
Information on the other fields in this request can be found in our Swagger documentation. Dimensions
Querying lists of metrics is similar to querying lists of dimensions. Request the list of available metrics for the report suite by calling the /metrics API method according to the following steps:
GET /metrics
geo1metrixxprod
in the rsid boxThis method returns a list of available metrics for the report suite. The response will look something like the following.
[
{
"id": "metrics/orders",
"title": "Orders",
"name": "Orders",
"type": "int",
"category": "Conversion",
"support": [
"oberon",
"dataWarehouse"
],
"allocation": true,
"precision": 0,
"calculated": false,
"segmentable": true,
"polarity": "positive"
},
...
]
We are interested in the title
field which is the friendly name of the metric and the id
which is the identifier needed to refer to this metric in a report request.
Information on the other fields in this request can be found in our Swagger documentation. Metrics
Now that you know how to get lists of metrics and dimensions, you are ready to run your first report. In Analysis Workspace, you simply drag dimensions and metrics into the table panel.
In order to run a report programmatically you need to construct a report request. Review the following request:
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000",
"type": "dateRange"
}
],
"metricContainer": {
"metrics": [
{
"id": "metrics/occurrences" <-- These metric id values come from the /metrics API method
}
]
},
"dimension": "variables/page" <-- This dimension id value comes from the /dimensions API method
}
A report request has several important parts:
The required rsid parameter specifies the report suite ID for the report suite that you want the data to come from.
The required globalFilters parameter contains a collection of filters that apply to the entire request. At a minimum a filter specifying the date range for the given report is required.
This required parameter defines all the metrics for the given report request and will be represented as the columns in the report response.
The array holds the metrics for the requested report. Metrics have two required parts to their definition: id and columnId. There is also an optional sort part of a metric definition.
The id of the metric. Use the /metrics or /calculatedmetrics API methods for the list of available options
The optional dimension parameter will cause the report to return data for a particular dimension. The dimension can be any dimension from the /dimensions API method, including the daterange dimensions.
/reports
to expand the documentation for that method{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000",
"type": "dateRange"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "occurrences",
"id": "metrics/occurrences"
}
]
},
"dimension": "variables/page"
}
Take a look at the results. Do they match this Analysis Workspace report?
Here is a partial example response:
{
"totalPages": 3,
"firstPage": true,
"lastPage": false,
"numberOfElements": 50,
"number": 0,
"totalElements": 149,
"columns": {
"dimension": {
"id": "variables/page",
"type": "string"
},
"columnIds": [
"0"
]
},
"rows": [
{
"itemId": "2897271828",
"value": "Search Results",
"data": [
4618
]
},
{
"itemId": "2080918144",
"value": "Shopping Cart: Cart Details",
"data": [
3853
]
},
{
"itemId": "3306266643",
"value": "Home",
"data": [
3612
]
}
...
],
"summaryData": {
"totals": [
39700
]
}
}
How many pages of data are in this response.
boolean value set to true if this is the first page
boolean value set to true if this is the last page.
Integer value specifying the number of rows in the current page
Integer value specifying the current page number
This is the total number of rows in this response
This object holds the description of the columns in the response.
This describes the dimension of the report response which will be represented as the itemId and value in the rows section of the response. The dimension has an id and a type.
This is an array of the columns or metrics represented in the report. The values in this array match the columnIds passed in on the request. If you didn't specify any columnIds in the request, the are generated for you.
This is an array of rows for the report response. Each row object has the following attributes
This is the id for this particular value of the dimension. This s the id value that you will need if you are going to perform breakdowns or reference this dimension value in future report requests.
This is the value of the dimension and will be the value that was passed into this dimension during data collection.
This is an array of data for the metrics that were requested in this report request. Reference the columnIds array in the columns object to understand what this data represents.
This is an array of aggregated or calculated data for this report.
This array holds the totals over the requested date range for the metrics in this report request. Reference the columnIds array in the columns object to understand what each item in the totals array represents.
/reports
to expand the documentation for that methodYou will need to edit the following JSON request before pasting into the body text box:
metrics/visitors
desc
to sort the Unique Visitors metric descendingmetrics/productinstances
metrics/cartadditions
variables/product
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "1",
"id": "<edit this>",
"sort": "<edit this>"
},
{
"columnId": "2",
"id": "<edit this>"
},
{
"columnId": "3",
"id": "<edit this>"
}
]
},
"dimension": "<edit this>"
}
Hint: A sort on column can be ascending ("asc") or descending ("desc")
Take a look at the results. Do they match the following Analysis Workspace report?
Congratulations! You've completed Lesson 2 and should understand the basic elements of running a report using the new Analytics V2 API. If you have some extra time you can try the optional Challenge below for some "extra credit", as well as explore the documentation further.
This step is optional, for those who have extra time and like a challenge. Using the Report API methods and techniques you've already learned, as well as the documentation, see if you can answer the following questions:
A breakdown report filters a dimension based on the specific value of another dimension
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "Product Views",
"id": "metrics/productinstances",
"filters": [
"0" <-- This references the filter by ID from the metricFilters section below
]
}
],
"metricFilters": [
{
"id": "0",
"type": "breakdown",
"dimension": "variables/evar6", <-- We are breaking down Product Type
"itemId": "1664911617"
}
]
},
"dimension": "variables/product" <-- by Product
}
When we breakdown Product Type by Product, we are actually filtering Product by a specific value of Product Type.
Breakdown the Product Type value of Boots by Product. You will need to make multiple report requests in this exercise. The first request will get the values for Product Type:
/reports
endpoint like in past exercises, first request the top values for the Product Type dimension with the Product Views metric.variables/evar6
metrics/productinstances
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "Product Views",
"id": "metrics/productinstances",
"sort": "desc"
}
]
},
"dimension": "variables/evar6"
}
The returned data should match the following:
{
"totalPages": 1,
"firstPage": true,
"lastPage": true,
"numberOfElements": 34,
"number": 0,
"totalElements": 34,
"columns": {
"dimension": {
"id": "variables/evar6",
"type": "string"
},
"columnIds": [
"Product Views"
]
},
"rows": [
{
"itemId": "1664911617", <-- We want to break down Boots so we need its specific itemId
"value": "Boots",
"data": [
2313
]
},
{
"itemId": "2271066348",
"value": "Jackets",
"data": [
1984
]
},
...
{
"itemId": "3642090695",
"value": "Helmets",
"data": [
50
]
}
],
"summaryData": {
"totals": [
12609
]
}
}
We want to break down the "Boots" Product Type by the Products in that category. We need to know the itemId for the value "Boots", which is "1664911617" as shown in the above result. The second request will do the actual breakdown:
1664911617
obtained from the first request, run a second request breaking down the "Boots" item by Product with the following report request:{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "Product Views",
"id": "metrics/productinstances",
"filters": [
"0"
]
}
],
"metricFilters": [
{
"id": "0",
"type": "breakdown",
"dimension": "variables/evar6",
"itemId": "1664911617"
}
]
},
"dimension": "variables/product"
}
Do the results match Analysis Workspace?
/reports
endpoint like in past exercises, first request the list of Pages using Analysis Workspace's default metric of Occurrences.You will need to edit the following JSON request before pasting into the body text box:
metrics/occurrences
variables/page
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "Occurrences",
"id": "<edit this>",
"sort": "desc"
}
]
},
"dimension": "<edit this>"
}
Do your results for Page values match Analysis Workspace?
itemId
value for the "Search Results" page in the results from step 1.You will need to edit the following JSON request before pasting into the body text box:
metrics/occurrences
0
0
breakdown
variables/page
2897271828
variables/browser
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "Occurrences",
"id": "<edit this>",
"filters": [
"<edit this>"
]
}
],
"metricFilters": [
{
"id": "<edit this>",
"type": "<edit this>",
"dimension": "<edit this>",
"itemId": "<edit this>"
}
]
},
"dimension": "<edit this>"
}
Do your results for the Search Results page broken down by Browser match Analysis Workspace?
Analysis Workspace can also do searches on dimension values.
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"id": "metrics/occurrences",
"sort": "desc"
}
]
},
"dimension": "variables/page",
"search": { <-- You need a search attribute
"clause": "( CONTAINS 'kids' )", <-- with a search clause
"includeSearchTotal" : true
}
}
A search attribute added to the report request will filter the dimensions in the report by the search clause. A search attribute must contain a clause attribute. All other attributes are optional. Search clauses can be very flexible and use the AND, OR, and NOT logical operators.
There are other search criteria besides CONTAINS:
/reports
endpoint like in past exercises, perform a search for any Page dimension values that contain the string kids
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "0",
"id": "metrics/occurrences",
"sort": "desc"
}
]
},
"dimension": "variables/page",
"search": {
"clause": "( CONTAINS 'kids' )",
"includeSearchTotal" : true
}
}
The response data will look something like this:
{
"totalPages": 1,
"firstPage": true,
"lastPage": true,
"numberOfElements": 1,
"number": 0,
"totalElements": 1,
"columns": {
"dimension": {
"id": "variables/page",
"type": "string"
},
"columnIds": [
"0"
]
},
"rows": [
{
"itemId": "3857221589",
"value": "Kids",
"data": [
1316
]
}
],
"summaryData": {
"totals": [
39700
],
"searchTotals": [
1316
]
}
}
/reports
endpoint like in past exercises, perform a search for any Page dimensions values that contain the string kids
OR the string home
.You will need to edit the following JSON request before pasting into the body text box:
( CONTAINS 'kids' ) OR ( CONTAINS 'home' )
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "0",
"id": "metrics/occurrences",
"sort": "desc"
}
]
},
"dimension": "variables/page",
"search": {
"clause": "<edit this>",
"includeSearchTotal" : true
}
}
Do your results match Analysis Workspace?
/reports
endpoint like in past exercises, perform a search for any Page dimensions that start with the value of Product
You will need to edit the following JSON request before pasting into the body text box:
BEGINS-WITH 'Product' )
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "0",
"id": "metrics/occurrences",
"sort": "desc"
}
]
},
"dimension": "variables/page",
"search": {
"clause": "<edit this>",
"includeSearchTotal" : true
}
}
Do your results match Analysis Workspace?
Congratulations! You've completed Lesson 3 and should understand breakdowns and searching in the new Analytics V2 API. If you have some extra time you can try the optional Challenge below for some "extra credit", as well as explore the documentation further.
This step is optional, for those who have extra time and like a challenge. Using the Report API methods and techniques you've already learned, as well as the documentation, see if you can answer the following questions:
Analysis Workspace presents users with lists of segments in the left rail. It uses the GET /segments
API method to get the list.
GET /segments
API methodshared
in the includeType field[
{
"id": "s300007301_5aa1af8b7f0bfd2308804475", <-- segment id
"name": "Browser contains Chrome",
"description": "",
"rsid": "geo1metrixxgeometrixx.outdoors",
"owner": {
"id": 722124
}
},
{
"id": "s300007301_5ab1b4fc5ef3a55946dce0d0",
"name": "Mobile Hits",
"description": "Mobile Hits",
"rsid": "geo1metrixxprod",
"owner": {
"id": 706903
}
}
]
id
returned from this response. We will need to use segment ids to reference segments in the report request.A global segment applies to the entire report request
POST /reports
API method as in previous exercises, run a report on the Browsers dimension and Occurrences metric using the segment "Browser Contains Chrome" as a global segment:{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "segment",
"segmentId": "s300007301_5aa1af8b7f0bfd2308804475"
},
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"id": "metrics/occurrences",
"sort": "desc"
}
]
},
"dimension": "variables/browser"
}
Does your result match Analysis Workspace?
A segment can be applied as a filter on one or more metrics rather than the entire report request
POST /reports
API method as in previous exercises, run a report on the Browsers dimension and Occurrences metric using the segment "Browser Contains Chrome" as a metric filter:You will need to edit the following JSON request before pasting into the body box
segment
s300007301_5aa1af8b7f0bfd2308804475
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"id": "metrics/occurrences",
"sort": "desc",
"filters": [
"0"
]
}
],
"metricFilters": [
{
"id": "0",
"type": "<edit this>",
"segmentId": "<edit this>"
}
]
},
"dimension": "variables/browser"
}
Does your result match Analysis Workspace?
Congratulations! You've completed Lesson 4 and should understand how to use segments in the new Analytics V2 API. If you have some extra time you can try the optional Challenge below for some "extra credit", as well as explore the documentation further.
This step is optional, for those who have extra time and like a challenge. Using the Report API methods and techniques you've already learned, as well as the documentation, see if you can answer the following questions:
You can use a time granularity as a dimension in Analysis Workspace report to get a trended report
{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"id": "metrics/occurrences"
}
]
},
"dimension": "variables/daterangehour", <-- The dimension is a time granularity
"settings": { <-- We need to add a "settings" section
"dimensionSort": "asc", <-- to specify sorting by dimension value instead of sorting by metric value
}
}
Valid time granularities are:
Minute: variables/daterangeminute
Hour: variables/daterangehour
Day: variables/daterangeday
Week: variables/daterangeweek
Month: variables/daterangemonth
Quarter: variables/daterangequarter
Year: variables/daterangeyear
The settings provide several parameters that control how the data is returned in the response.
Sets an upper limit on the number of data rows to return. The default is 50.
The page number when you want to chunk up the requests. Example: If the date range we are reporting against has 90 days worth of data setting the page attribute to 0 with a limit of 50 would return the first 50 days. Setting page to 1 would return the remaining 40 days.
The sort direction of the data ("asc" for ascending, "desc" for descending). Including this attribute will sort the data by the dimension values instead of by a metric.
Trend the Occurrences metric by hour.
POST /reports
endpoint as in past exercises, paste the following JSON report request into the body text box:{
"rsid": "geo1metrixxprod",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2018-03-01T00:00:00.000/2018-03-04T00:00:00.000"
}
],
"metricContainer": {
"metrics": [
{
"id": "metrics/occurrences"
}
]
},
"dimension": "variables/daterangehour",
"settings": {
"dimensionSort": "asc"
}
}
Congratulations! You've completed Lesson 5 and should understand how to request trended reports. If you have some extra time you can try the Optional Challenge below for some "extra credit", as well as explore the documentation further.
This step is optional, for those who have extra time and like a challenge. Using the Report API methods and techniques you've already learned, as well as the documentation, see if you can answer the following questions:
The new Analytics V2 API powers Analysis Workspace. Analysis Workspace includes a debugger that will let you view the different API requests it makes. This debugger is very helpful in learning how to craft report requests and exploring the full power of the new Analytics API.
Log into Analysis Workspace as described in Lesson 1
Click on the Create New Project button to create a new project
Scroll down and select the Products template
Open the browser's developer tools
On a Mac:
On a PC:
Select the Console tab and enter adobe.tools.debug.includeOberonXml = true
into the console and press Enter.
Refresh the page
Notice that you now have a debugger icon on every panel!
Locate the Product Performance Grid panel in the Analysis Workspace project and click on the debugger icon, then click on Freeform Table
Notice that there are possibly multiple requests per panel
Click on one of the requests
Copy the text from the JSON REQUEST box by either manually selecting the text or using the handy Copy to Clipboard button
Click the Try it out! button
Paste the JSON into the /reports
endpoint in the Swagger interface
Click the Execute
Do your results match Analysis Workspace?
Open the browser's developer tools again
On a Mac:
On a PC:
Select the Console tab and enter adobe.tools.debug.includeOberonXml = false
into the console and press Enter.
Refresh the page. The debug icon should be gone.
Congratulations! You have completed Lesson 6 and should know how to use the Analysis Workspace debugger to help you format report requests.
You have completed the lab! If you have additional time, you can try some of the Extra Credit Challenges in the previous lessons.