Auditing the Dimensions of Your Report Suites using the Analytics API

January 28, 2024

Joining an organization or working as a consultant, you’ll eventually need to review their implementations from the implementation to the backend configuration within Adobe Analytics. One likely task is going to be comparing how each of the report suites has their various dimensions configured to check for inconsistencies across report suites. Fortunately this is easy enough using Python and the 2.0 Analytics API with a few basic manipulations.

To get started, here’s a link to the API documentation: https://developer.adobe.com/analytics-apis/docs/2.0/guides/endpoints/

As usual, the documentation is kind of sparse or at least I never know where to look for the details so I end up experimenting with the results and scanning the examples. I found that the the query params and default response sizes of the various endpoints varies.

What you’ll see below is a starter for working with your basic report suite configurations info via the API. The only real tweak I’m applying here is pivoting on the dimension ‘id’ along with the ‘name’ and ‘rsid’. I chose to do this because when I export the results into Excel or Google Sheets, we can add conditional formatting to tell us which values are different across a row so we can review them accordingly.

import requests
from authlib.integrations.requests_client import OAuth2Session
import json
import pandas as pd

# Configure the Adobe Analytics API credentials
client_id = ''
client_secret = ''
token_endpoint = 'https://ims-na1.adobelogin.com/ims/token/v3'
company_name = ''

# Create an OAuth2Session object with the client credentials
oauth = OAuth2Session(client_id, client_secret, scope='openid AdobeID additional_info.projectedProductContext')

# Fetch the access token from Adobe IMS
token = oauth.fetch_token(token_endpoint)

# config the request
api_url = r'https://analytics.adobe.io/api/{}/reportsuites/collections/suites?limit=50'.format(company_name)
headers = {
    'Authorization': 'Bearer ' + token['access_token'],
    'x-api-key': client_id
}
response = requests.get(api_url, headers=headers)

if response.status_code == 200:
    data = response.json()
    #here we flatten the response for a simple table
    reportSuites = pd.json_normalize(data.get('content'))
    reportSuitesDf = pd.DataFrame()
    #now that we have the rsids we can iterate and concat for reach report suite
    for index, reportSuite in reportSuites.iterrows():

        rsid = reportSuite['rsid']
        rsidUrl = r'https://analytics.adobe.io/api/{}/dimensions?rsid={}'.format(company_name, rsid)
        rsidResponse = requests.get(rsidUrl, headers=headers)
        if rsidResponse.status_code == 200:
            rsidData = rsidResponse.json()
            rsidDf = pd.json_normalize(rsidData)
            rsidDf['rsid'] = rsid
            reportSuitesDf = pd.concat([reportSuitesDf, rsidDf])
    
    #some cleanup for readability
    reportSuitesDf['id'] = reportSuitesDf['id'].str.replace('variables/','')
    reportSuitesDf.to_csv('report_suite_dimensions.csv',index=False)
    
    #pivoting on the ID, Name, and RSID so we can compare against each other
    pivoted_df = reportSuitesDf.pivot(index='id', columns='rsid', values='name')
    pivoted_df.to_csv('pivoted_dimensions.csv')

else:
    print('Error:', response.status_code, response.text)

While this isn’t a task you’ll need to perform very often if you aren’t a consultant, it’s still a useful tool to help augment other ‘offline’ documentation like your SDRs or other tracking documents and measurement plans.

The next step for me will be establishing the baseline configuration via the available data and other information to create the SDR. The organization has no formal SDR but a pdf which really describes the implementation overall, this way we can build the SDR into an automated auditing process.

After that, I’ll be comparing the SDR and current report suite configurations against the Adobe Launch or Tags Data Collection configuration via the XDM Data Element configurations.

The goal after filling gaps and repairing any bugs will be to have comprehensive documentation on the implementation in one single place. Even building a dashboard where a user can click on a given evar or prop and then be taken to information on how it is implemented in Launch to better understand the origin of the data.


Welcome!

To learn something new, I've put together this site using Gatsby with WordPress and GraphQL, along with a server-side GTM configuration for a first party analytics ecosystem.

Aris

Explore when and wherever you can!

Find me on LinkedIn