Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →Analyze Adobe Target Data in R via JDBC
Use standard R functions and the development environment of your choice to analyze Adobe Target data with the CData JDBC Driver for Adobe Target.
Access Adobe Target data with pure R script and standard SQL on any machine where R and Java can be installed. You can use the CData JDBC Driver for Adobe Target and the RJDBC package to work with remote Adobe Target data in R. By using the CData Driver, you are leveraging a driver written for industry-proven standards to access your data in the popular, open-source R language. This article shows how to use the driver to execute SQL queries to Adobe Target and visualize Adobe Target data by calling standard R functions.
Install R
You can match the driver's performance gains from multi-threading and managed code by running the multithreaded Microsoft R Open or by running open R linked with the BLAS/LAPACK libraries. This article uses Microsoft R Open 3.2.3, which is preconfigured to install packages from the Jan. 1, 2016 snapshot of the CRAN repository. This snapshot ensures reproducibility.
Load the RJDBC Package
To use the driver, download the RJDBC package. After installing the RJDBC package, the following line loads the package:
library(RJDBC)
Connect to Adobe Target as a JDBC Data Source
You will need the following information to connect to Adobe Target as a JDBC data source:
- Driver Class: Set this to cdata.jdbc.adobetarget.AdobeTargetDriver
- Classpath: Set this to the location of the driver JAR. By default this is the lib subfolder of the installation folder.
The DBI functions, such as dbConnect and dbSendQuery, provide a unified interface for writing data access code in R. Use the following line to initialize a DBI driver that can make JDBC requests to the CData JDBC Driver for Adobe Target:
driver <- JDBC(driverClass = "cdata.jdbc.adobetarget.AdobeTargetDriver", classPath = "MyInstallationDir\lib\cdata.jdbc.adobetarget.jar", identifier.quote = "'")
You can now use DBI functions to connect to Adobe Target and execute SQL queries. Initialize the JDBC connection with the dbConnect function.
To connect to Adobe Target, you must provide the Tenant property along with OAuth connection properties mentioned below. Note that while other connection properties can influence processing behavior, they do not affect the ability to connect.
To determine your Tenant name:
- Log in to Adobe Experience. The URL will look similar to: "https://experience.adobe.com/#/@mycompanyname/preferences/general-section".
- Extract the value after the "/#/@". In this example, it is "mycompanyname".
- Set the Tenant connection property to that value.
User Accounts (OAuth)
You must set AuthScheme to OAuthClient for all user account flows.
Note: Adobe authentication via OAuth requires updating your token every two weeks.
All Applications
CData provides an embedded OAuth application that simplifies OAuth authentication. Alternatively, you can create a custom OAuth application. Review Creating a Custom OAuth App in the Help documentation for more information.Obtaining the OAuth Access Token
Set the following properties to connect:
- InitiateOAuth: Set to GETANDREFRESH to automatically perform the OAuth exchange and refresh the OAuthAccessToken as needed.
- OAuthClientId : Set to the client Id assigned when you registered your app.
- OAuthClientSecret : Set to the client secret assigned when you registered your app.
- CallbackURL : Set to the redirect URI defined when you registered your app. For example: https://localhost:3333
With these settings, the provider obtains an access token from Adobe Target, which it uses to request data. The OAuth values are stored in the location specified by OAuthSettingsLocation, ensuring they persist across connections.
Built-in Connection String Designer
For assistance in constructing the JDBC URL, use the connection string designer built into the Adobe Target JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.
java -jar cdata.jdbc.adobetarget.jar
Fill in the connection properties and copy the connection string to the clipboard.
Below is a sample dbConnect call, including a typical JDBC connection string:
conn <- dbConnect(driver,"jdbc:adobetarget:Tenant=mycompanyname;InitiateOAuth=GETANDREFRESH")
Schema Discovery
The driver models Adobe Target APIs as relational tables, views, and stored procedures. Use the following line to retrieve the list of tables:
dbListTables(conn)
Execute SQL Queries
You can use the dbGetQuery function to execute any SQL query supported by the Adobe Target API:
activities <- dbGetQuery(conn,"SELECT Id, Name FROM Activities WHERE Type = 'AB'")
You can view the results in a data viewer window with the following command:
View(activities)
Plot Adobe Target Data
You can now analyze Adobe Target data with any of the data visualization packages available in the CRAN repository. You can create simple bar plots with the built-in bar plot function:
par(las=2,ps=10,mar=c(5,15,4,2)) barplot(activities$Name, main="Adobe Target Activities", names.arg = activities$Id, horiz=TRUE)