Real-Time Reporting Adobe Analytics API Tutorial

adobe_analytics_real-time_dashboard_sample_

Adobe has a nice real-time dashboard built directly into Reports & Analytics (SiteCatalyst). It is easy to configure and get up and running quickly. According to Adobe product manager Ben GainesReal-Time reports in Adobe Analytics has become one of the most popular features in Reports & Analytics.” What you may not know is that real-time data can be accessed via Adobe’s reporting API. Adobe has a great tutorial on how to get started with the Adobe Analytics Real-Time API that you need to check out. The example was used in a lab session at past Adobe Summits and it looks like it was offered again at the 2016 Adobe Summit. If you went to Summit let me know how the session was. I haven’t attended the session before, but I was in search of a real-time API sample for Adobe Analytics and I stumbled upon this gem.

In this post I am going to walk you through Lesson 1 and Lesson 6 from this tutorial. Lesson 1 gives you the basic fundamentals needed to run a Adobe Analytics real-time report. Lesson 6 gives you a working real-time dashboard with snazzy D3.js visualizations that you can load right now in your browser. Hopefully you can use this as the foundation for building some actionable solutions that leverage real-time data at your organization. I look forward to hearing about the real-time dashboard you build or the real-time content and campaign optimization or the real-time site health alert tools. Please share what you create in the comments or @ryanpraski.

Lesson 1

Start by downloading the analytics realtime dashboard example from GitHub. Find this in your downloads and unzip it. I unzipped the folder on my desktop for this example.

View Real-Time Reports in Adobe Analytics Reports & Analytics

1) Find the Lesson 1 folder on your computer. The path to the folder on my computer is: C:\Users\ryanpraski\Desktop\analytics-realtime-dashboard-example-master\lessons\lesson_1

2) Open the README file in the lesson_1 folder in your text editor or on GitHub.

3) You will have to use your own Adobe Analytics login and password and not the lab password listed in lesson 1.

4) Login to Adobe Analytics and in Reports & Analytics click View All Reports > Site Metrics > Real-Time. You can switch between the 3 real-time reports that have been previously setup by an Admin at your company by clicking on the links next to “Reports:” just below the top nav.

5) If the report suite selected does not have a real-time report configured you will see this message: “Report Suite Not Yet Configured. This report suite has not yet been configured for Real-Time reporting. Click here to setup this report suite for Real-Time.” If you are an Admin you will be able to click the link to setup Real-Time. Make sure “Enable Real-Time” is set to On. Then give your real-time report a name and select a metric, primary dimension and two secondary dimensions. For the example I selected Instances as my metric, Page as my primary dimension and Site Section and Referring Domain as my secondary dimensions. Click Save and View Report and you should start to see real-time data.

https://i0.wp.com/www.ryanpraski.com/wp-content/uploads/2016/01/adobe_analytics_real_time_report_config.png?resize=550%2C235

Pull a Real-Time Report with the Adobe Analytics Reporting API

1) You will have to use your own Adobe Analytics API credentials not the lab credentials listed in lesson 1. If you are an admin go to User Management and select your login and click on edit. Make sure you are part of the Web Services Access Group and retrieve your Web Services User Name and Shared Secret from the green box in the access section. If you don’t have admin access request this info from someone who does have access.

Web Services Credentials
User Name: username:company name
Shared Secret: abcdefghijklmnopgrstuvwxyz

2) Go to the Adobe Analytics API Query Explorer and enter your API User Name and Shared Secret. The API “Report” and Method “Run” should be selected. If they are not automatically selected then select them from the drop downs.

3) Copy the code below and paste it over the code that is pre-populated in the JSON query box. Make sure to change “rtd-example” to your actual report suite in the code. Then click the Get Response button. You should see the results of your query in the Response box at the bottom of page showing page views every 5 minutes for the last hour.

4) There are several other more detailed sample queries in the Lesson 1 documentation that you can work through. Just make sure to swap out the “rtd-example” report suite with your own report suite before you run the queries. There is additional documentation from Adobe here that shows sample queries and includes the different parameters you can use in a real-time report request.

5) Here is a more detailed sample real-time query: Top 100 product revenue every 2 minutes for the last 2 hours where the product name contains skis or boots. Currently top 100 is the maximum for any real-time query. This code is for version 1.4 of the Adobe Analytics API.

6) Here is another example showing how to apply multiple filters to an Adobe Analytics real-time API query. In this case I want to alter the query from above slightly to include pages that contain skis or boots in the page name but do not contain salomon or atomic (this are brands of skis and boots). This code is for version 1.4 of the Adobe Analytics API.

Now let’s skip to Lesson 6 where everything from Lessons 1-5 comes together into a web based real-time dashboard that automatically updates. The dashboard uses  jQuery, and D3.js for some slick data visualization.

Lesson 6

Create a Snazzy Real-Time Adobe Analytics Dashboard Now

1) Since we skipped Lesson 2-5 you’ll have to update the config.js file in the analytics-realtime-dashboard-example-master that you downloaded. The path to the file on my computer is: C:\Users\ryanpraski\Desktop\analytics-realtime-dashboard-example-master\js\config.js

Below is a sample config.js file. Make sure to update it with your credentials and save it on your computer.

2) Find the Lesson 6 folder on your computer. The path to the folder on my computer is: C:\Users\ryanpraski\Desktop\analytics-realtime-dashboard-example-master\lessons\lesson_6

3) Open the README file in the lesson_6 folder in your text editor or on GitHub.

4) Open the lesson_6.html file in your web browser and then open it a second time in a text editor. The path to the folder on my computer is: C:\Users\ryanpraski\Desktop\analytics-realtime-dashboard-example-master\lessons\lesson_6\lesson_6.html

5) When you load the lesson_6.html file in your browser you should see an animated number flash on the screen of total page views for the past 15 minutes in the top left, a continuously updating trend line with page views by minute for the past 15 minutes, and a table with the top 10 pages by page views for the last 15 minutes.

6) Follow the instructions in the lesson_6 README file to add the donut chart to your dashboard. If you have trouble getting the the donut chart included on your lesson_6.html file, you can open a complete version of the dashboard with the Lesson 6 code updates already done for you. The path to this complete “final dashboard” file on my computer is: C:\Users\ryanpraski\Desktop\analytics-realtime-dashboard-example-master\index.html

7) Your real-time dashboard should look like the screen shot below and will dynamically update with real-time Adobe Analytics data from the reporting API.

adobe_analytics_real-time_dashboard_sample_

8) If you’d like to create a different report that uses the same visualizations change the query parameters in the lesson_6.html or index.html file within the var params show in the code snippet below:

Your Turn: Create Your Own Real-Time Dashboard or Real-Time Campaign Optimization Tool

I hope this tutorial opens your eyes to what is possible with real-time data and gives you a solid understanding of how to pull real-time data from the Adobe Analytics reporting API. Thanks to the Adobe Analytics team for sharing such a great tutorial with the world. Hopefully it inspires you to build your own dashboard or solution that leverages real-time data. Here are some ideas for solutions: real-time campaign optimization, real-time site health alerting, and real-time content optimization. If you are interested in other tutorials on how to get started with the Adobe Analytics API check these out:

How to Add 100 Users to Adobe Analytics in Seconds

Using the Adobe Analytics API for Report Suite Configuration

Also, check out @randyzwitch‘s Adobe Analytics API package for R called RSiteCatalyst.

Please share any comments, questions, or ideas for real-time solutions in the comments below or @ryanpraski.

  • Peter Cardel Rosenkjær

    Hi,

    Does the Real-TIme API support the use of segments?

    …somthing like this?

    var params = {
    “reportDescription”: {
    “source”: “realtime”,
    “reportSuiteID”: config.reportSuite,
    “metrics”: [
    { “id”: “pageviews” }
    ], “elements”: [
    { “id”: “page” }
    ],
    “segments”:[
    {“id”:”5663e02fe4b00a37e7403fe0″}
    ],
    “dateGranularity”: “minute:1”,
    “dateFrom”: “-60 minutes”
    }
    };

    I can’t find anything in the documentation – not directly related to Real-Time

    Pls help me 🙂

    /P

    • Hi Peter,
      No you cannot currently apply segments to Adobe Analytics real-time reports. You can apply filters to real-time reports

      Best,
      Ryan

      • Peter Cardel Rosenkjær

        Thx Ryan this really helped me a lot. Is there any clever way i can make a search that combines AND and NOT something like

        “search”: { “type”: “AND”, “keywords”: [“YYYY” ,”CCCCCC”] },
        “search”: { “type”: “NOT”, “keywords”: [“XXXXX”] },

        I have tried a lot of different combinations…and nothing works…

        /P

        • Hi Peter,

          To apply multiple filters to an Adobe Analytics API Query try using the sample API query code below:

  • Luke

    Hi Ryan,

    Can you tell me if Products report is enabled with Real-time in order to get the value using API? I see the Developer connection say that it is possible, however I get the below issue when I execute. Please note that i have replaced my original report suite.

    Code:
    {
    “reportDescription”:{
    “source”: “realtime”,
    “dateGranularity”: “minute:10”,
    “reportSuiteID”:””,
    “metrics”:[
    {“id”:”pageviews”}
    ],
    “elements”:[
    { “id”: “product”}
    ],
    }

    }

    Response:

    {
    “error”:”realtime_report_invalid”,
    “error_description”:”This report is not configured for realtime”,
    “error_uri”:”https://marketing.adobe.com/developer/documentation/analytics-reporting-1-4/errors”
    }

  • Nobodyreally

    Hi, Ryan, Thanks for doing this. I attended the class this year, but their templates don’t fit into the data table, but rather display as raw code. This has been very helpful.

    This may sound as a very stupid question/request, but here it is. While I like the donut, number and all that, I basically want to generate several tables in one page. I’ve removed the trend chart, number widget and donut chart and now I have the table.

    If I wanted to generate a second, third or fourth table, following the same parameters you gave us, how would that work?

    Again, thanks for writing this out, it was extremely handy.

    Best,
    Emilio

  • Peter Cardel Rosenkjær

    Hi Ryan, do you know how easy it is to change the code provided from https://github.com/Adobe-Marketing-Cloud/analytics-realtime-dashboard-example/ so it can display not real-time data but just regular Analytics API 1.4 request.

    My reason for this is that i would like to use segments and other features that are not available in real-time?

    Your help is really appreciated.

    -Peter

  • Peter Cardel Rosenkjær

    https://uploads.disquscdn.com/images/7a1d17f867c92689c85cb3bb543c6cf3ecad3e20cc71f15e7ad91e2be62b15e0.png

    Hi Ryan,

    You have helped me so many times. Yet another question. The topic is still real-time-reporting. Is it possible to get the following data (see the attached image) in two requests – one request for the total and one request for the amount of pageviews (granularity: 5min – period: last hour).

    Best regards

    Peter

    • Hi Peter,

      The query below will give you total real-time page-views for the past hour dateFrom and will also break it out by 15 minute intervals using dateGranularity.