![]() |
VOOZH | about |
The CData ODBC Driver for Adobe Analytics makes it easy to integrate connectivity to live Adobe Analytics data in Ruby. This article shows how to create a simple Ruby app that connects to Adobe Analytics data, executes a query, and displays the results.
If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.
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.
If you do not have Ruby installed, refer to the Ruby installation page. With Ruby installed, you will need to install the ruby-dbi, dbd-odbc, and ruby-odbc gems:
gem install dbi gem install dbd-odbc gem install ruby-odbc
Create a new Ruby file (for example: AdobeAnalyticsSelect.rb) and open it in a text editor. Copy the following code into your file:
#connect to the DSN
require 'dbi'
cnxn = DBI.connect('DBI:ODBC:CData AdobeAnalytics Source','','')
#execute a SELECT query and store the result set
resultSet = cnxn.execute("SELECT Page, PageViews FROM AdsReport WHERE City = 'Chapel Hill'")
#display the names of the columns
resultSet.column_names.each do |name|
print name, "\t"
end
puts
#display the results
while row = resultSet.fetch do
(0..resultSet.column_names.size - 1).each do |n|
print row[n], "\t"
end
puts
end
resultSet.finish
#close the connection
cnxn.disconnect if cnxn
With the file completed, you are ready to display your Adobe Analytics data with Ruby. To do so, simply run your file from the command line:
ruby AdobeAnalyticsSelect.rbWriting SQL-92 queries to Adobe Analytics allows you to quickly and easily incorporate Adobe Analytics data into your own Ruby applications. Download a free trial today!
Download a free trial of the Adobe Analytics ODBC Driver to get started:
Download NowLearn more:
👁 Adobe Analytics IconThe Adobe Analytics ODBC Driver is a powerful tool that allows you to connect with live Adobe Analytics data, directly from any applications that support ODBC connectivity.
Access Adobe Analytics like you would a database - access Metrics, Users, Reports, Segments, etc. through a standard ODBC Driver interface.