![]() |
VOOZH | about |
The rich ecosystem of Python modules lets you get to work quickly and integrate your systems more effectively. With the CData Python Connector for Adobe Analytics, the pandas module, and the Dash framework, you can build Adobe Analytics-connected web applications for Adobe Analytics data. This article shows how to connect to Adobe Analytics with the CData Connector and use pandas and Dash to build a simple web app for visualizing Adobe Analytics data.
With built-in, optimized data processing, the CData Python Connector offers unmatched performance for interacting with live Adobe Analytics data in Python. When you issue complex SQL queries from Adobe Analytics, the driver pushes supported SQL operations, like filters and aggregations, directly to Adobe Analytics and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations).
Connecting to Adobe Analytics data looks just like connecting to any relational data source. Create a connection string using the required connection properties. For this article, you will pass the connection string as a parameter to the create_engine function.
Adobe Analytics uses the OAuth authentication standard. To authenticate using OAuth, create an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties. See the "Getting Started" section of the help documentation for a guide.
GlobalCompanyId is a required connection property. If you do not know your Global Company ID, you can find it in the request URL for the users/me endpoint on the Swagger UI. After logging into the Swagger UI Url, expand the users endpoint and then click the GET users/me button. Click the Try it out and Execute buttons. Note your Global Company ID shown in the Request URL immediately preceding the users/me endpoint.
Report Suite ID (RSID) is also a required connection property. In the Adobe Analytics UI, navigate to Admin -> Report Suites and you will get a list of your report suites along with their identifiers next to the name.
After setting the GlobalCompanyId, RSID and OAuth connection properties, you are ready to connect to Adobe Analytics.
After installing the CData Adobe Analytics Connector, follow the procedure below to install the other required modules and start accessing Adobe Analytics through Python objects.
Use the pip utility to install the required modules and frameworks:
pip install pandas pip install dash pip install dash-daq
Once the required modules and frameworks are installed, we are ready to build our web app. Code snippets follow, but the full source code is available at the end of the article.
First, be sure to import the modules (including the CData Connector) with the following:
import os import dash import dash_core_components as dcc import dash_html_components as html import pandas as pd import cdata.adobeanalytics as mod import plotly.graph_objs as go
You can now connect with a connection string. Use the connect function for the CData Adobe Analytics Connector to create a connection for working with Adobe Analytics data.
cnxn = mod.connect("GlobalCompanyId=myGlobalCompanyId; RSID=myRSID; OAuthClientId=myOauthClientId; OauthClientSecret=myOAuthClientSecret; CallbackURL=myCallbackURL;")
Use the read_sql function from pandas to execute any SQL statement and store the result set in a DataFrame.
df = pd.read_sql("SELECT Page, PageViews FROM AdsReport WHERE City = 'Chapel Hill'", cnxn)
With the query results stored in a DataFrame, we can begin configuring the web app, assigning a name, stylesheet, and title.
app_name = 'dash-adobeanalyticsedataplot' external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) app.title = 'CData + Dash'
The next step is to create a bar graph based on our Adobe Analytics data and configure the app layout.
trace = go.Bar(x=df.Page, y=df.PageViews, name='Page')
app.layout = html.Div(children=[html.H1("CData Extension + Dash", style={'textAlign': 'center'}),
dcc.Graph(
id='example-graph',
figure={
'data': [trace],
'layout':
go.Layout(title='Adobe Analytics AdsReport Data', barmode='stack')
})
], className="container")
With the connection, app, and layout configured, we are ready to run the app. The last lines of Python code follow.
if __name__ == '__main__': app.run_server(debug=True)
Now, use Python to run the web app and a browser to view the Adobe Analytics data.
python adobeanalytics-dash.py👁 Adobe Analytics data in a Dash web app (Salesforce is shown).
Download a free, 30-day trial of the CData Python Connector for Adobe Analytics to start building Python apps with connectivity to Adobe Analytics data. Reach out to our Support Team if you have any questions.
import os
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import cdata.adobeanalytics as mod
import plotly.graph_objs as go
cnxn = mod.connect("GlobalCompanyId=myGlobalCompanyId; RSID=myRSID; OAuthClientId=myOauthClientId; OauthClientSecret=myOAuthClientSecret; CallbackURL=myCallbackURL;")
df = pd.read_sql("SELECT Page, PageViews FROM AdsReport WHERE City = 'Chapel Hill'", cnxn)
app_name = 'dash-adobeanalyticsdataplot'
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.title = 'CData + Dash'
trace = go.Bar(x=df.Page, y=df.PageViews, name='Page')
app.layout = html.Div(children=[html.H1("CData Extension + Dash", style={'textAlign': 'center'}),
dcc.Graph(
id='example-graph',
figure={
'data': [trace],
'layout':
go.Layout(title='Adobe Analytics AdsReport Data', barmode='stack')
})
], className="container")
if __name__ == '__main__':
app.run_server(debug=True)
Download a Community License of the Adobe Analytics Connector to get started:
Download NowLearn more:
👁 Adobe Analytics IconPython Connector Libraries for Adobe Analytics Data Connectivity. Integrate Adobe Analytics with popular Python tools like Pandas, SQLAlchemy, Dash & petl.