Using search clause in reporting API and sorting data by metric | Community
Skip to main content
Level 2
November 7, 2018
Solved

Using search clause in reporting API and sorting data by metric

  • November 7, 2018
  • 7 replies
  • 7516 views

Hi,

I am trying to retrieve data provided in a report using the Adobe Reporting API.

I have a pages report and would like to get top 20 pages containing a specific keyword and sorted by pageviews on a specific date. I see that search clause helps you search by dimension but not sure how to use it in the json response code. Also, is there a way to sort by metric. My dimension is Page and Metric is Pageviews.

Thank you!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by truptig90

Yes, I was able to get the exact json request required using the below steps:

Using Adobe Analytics interface

Using the debugger to get request and access_token

  1. Go to Analysis Workspace and open the report that you want to reproduce via API.
  2. Open a the developer console in your browser and input

    1. adobe.tools.debug.includeOberonXml = true 
  3. Reload the page and you should see an orange bug next to each table and visualisations
  4. Click on the orange bug
  5. Click on Freeform tables
  6. Select entry with the most up to date date
  7. A screen should be displayed with title Oberon request

Analytics API thanks to

Alexis Cazes Adobe

7 replies

Gigazelle
Adobe Employee
Adobe Employee
November 14, 2018

You would want to use a segment instead of search. If you only pull in a single dimension, it will automatically sort by that.

Are you using the v1.4 or v2.0 API?

Urs_Boller
Community Advisor
Community Advisor
November 14, 2018

In API 1.4 you can't filter on a dimension directly, a call like "where page contains 'help' or 'contact'" does not work. the "contains" is only supported for classifications. what you need here are inline segments: https://github.com/AdobeDocs/analytics-1.4-apis/blob/master/docs/reporting-api/inline_segments.md

as a workaround you could add a classification to the desired dimension (eg. "page copy") and just copy the original value to the classified one by simply use a regex rule ".*"

havin g the classified value (which is basically the original one) allows to filter by a "contains"

and as Gigazelle​ said, it's always ordered by the metric by default or what you indicate in the API call. see "sortby" here: https://github.com/AdobeDocs/analytics-1.4-apis/blob/master/docs/reporting-api/data_types/r_reportDescription.md

truptig90Author
Level 2
November 16, 2018

We are using API 2.0. I was able to search pages by adding search clause:

"dimension": "variables/page",

    "search": {

        "clause": "( CONTAINS 'contact' )"

    },

Urs_Boller
Community Advisor
Community Advisor
November 16, 2018

if you are using API 2.0 and open console to inspect the API calls. that means you can build the desired table in workspace and have your API call in the network traffic.

There is even a hidden feature which allows you to show a debug mode and directly inspect the API for each table. can't find the link anymore, maybe ericmatisoff​ or Gigazelle​ have the link?

truptig90AuthorAccepted solution
Level 2
November 16, 2018

Yes, I was able to get the exact json request required using the below steps:

Using Adobe Analytics interface

Using the debugger to get request and access_token

  1. Go to Analysis Workspace and open the report that you want to reproduce via API.
  2. Open a the developer console in your browser and input

    1. adobe.tools.debug.includeOberonXml = true 
  3. Reload the page and you should see an orange bug next to each table and visualisations
  4. Click on the orange bug
  5. Click on Freeform tables
  6. Select entry with the most up to date date
  7. A screen should be displayed with title Oberon request

Analytics API thanks to

Alexis Cazes Adobe

Urs_Boller
Community Advisor
Community Advisor
November 16, 2018

exactly what I was looking for. thanks for posting it!

keremkulak
Level 2
May 3, 2019

"dimension": "variables/page" this statement saved my whole week.Thank you