![]() |
VOOZH | about |
The CData ADO.NET Provider for Adobe Analytics is fully integrated into the SAP Crystal Reports for Visual Studio development environment. You can employ standard ADO.NET components to construct reports, much like you would with SQL Server, but with the added advantage of real-time connectivity to Adobe Analytics. This article will guide you through the essential three steps to incorporate Adobe Analytics data into a report that refreshes upon opening.
Note: You will need to install SAP Crystal Reports, developer version for Visual Studio to follow this tutorial.
To follow this article, you will also need a Visual Studio Crystal Reports project. This article will add a report to a WPF application. You can create one by clicking File -> New Project and then selecting the Crystal Reports WPF Application template. In the resulting wizard, select the option to create a blank report.
Creating an ADO.NET data source for Adobe Analytics from Server Explorer makes it easy to create a DataSet that can be used in Crystal Reports wizards and the Crystal Reports Designer. You can find a guide to working with Adobe Analytics data in Server Explorer in the "Getting Started" chapter of the help documentation.
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.
When you configure the connection, you may also want to set the Max Rows connection property. This will limit the number of rows returned, which is especially helpful for improving performance when designing reports and visualizations.
Follow the steps below to use the Visual Studio ADO.NET DataSet Designer to create an ADO.NET DataSet object. Crystal Reports will bind to the DataSet object, which contains Adobe Analytics table metadata. Note that this approach also adds a connection string to App.config; you will use this connection string later to load data into the report.
Follow the steps below to add columns from the DataSet to the report:
Having created the DataSet, which will only contain the metadata, you will now need to create the DataTable containing the actual data. You can use the AdobeAnalyticsDataAdapter to fill a DataTable with the results of an SQL query.
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup>
Add the following references in your Window.xaml.cs file:
using System.Configuration; using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; using System.Data.CData.AdobeAnalytics; using System.Data;
Add the following Window_Loaded method in your Window.xaml.cs to execute the SQL query that will return the DataTable. Note that your query needs to select at least the same columns used in your report.
private void Window_Loaded(object sender, RoutedEventArgs e) {
ReportDocument report = new ReportDocument();
report.Load("../../CrystalReport1.rpt");
var connectionString = ConfigurationManager.ConnectionStrings["MyAppConfigConnectionStringName"].ConnectionString;
using (AdobeAnalyticsConnection connection = new AdobeAnalyticsConnection(connectionString)) {
AdobeAnalyticsDataAdapter dataAdapter = new AdobeAnalyticsDataAdapter(
"SELECT Page, PageViews FROM AdsReport WHERE City = 'Chapel Hill'", connection);
DataSet set = new DataSet("_set");
DataTable table = set.Tables.Add("_table");
dataAdapter.Fill(table);
report.SetDataSource(table);
}
reportViewer.ViewerCore.ReportSource = report;
}
In the Window.xaml file, add the Loaded event so that your Window tag resembles the following:
<Window x:Class="CrystalReportWpfApplication4.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cr="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer" Title="WPF Crystal Report Viewer" Height="600" Width="800" Loaded="Window_Loaded"> ... </Window>
You can also use the DataSet with experts like the Chart Expert:
Note that Crystal Reports performs the aggregation on the data already loaded into DataTable, instead of, for example, executing a GROUP BY to the Adobe Analytics API. This will also be true for the report creation wizards.
You could gain more control over the queries executed to Adobe Analytics by creating another DataSet and populating it with a different query. See the help documentation for more information on the driver's SQL engine.
👁 DataSet columns to be added to a chart. (Salesforce is shown.)Download a free trial of the Adobe Analytics Data Provider to get started:
Download NowLearn more:
👁 Adobe Analytics IconRapidly create and deploy powerful .NET applications that integrate with Adobe Analytics data including Metrics, Users, Reports, Segments, and more!