Ready to get started?

Download a free trial of the Adobe Analytics Data Provider to get started:

 Download Now

Learn more:

Adobe Analytics Icon Adobe Analytics ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Adobe Analytics data including Metrics, Users, Reports, Segments, and more!

Automate Adobe Analytics Integration Tasks from PowerShell



Are you in search of a quick and easy way to access Adobe Analytics data from PowerShell? This article demonstrates how to utilize the Adobe Analytics Cmdlets for tasks like connecting to Adobe Analytics data, automating operations, downloading data, and more.

The CData Cmdlets for Adobe Analytics are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Adobe Analytics.

PowerShell Cmdlets or ADO.NET Provider?

The Cmdlets are not only a PowerShell interface to Adobe Analytics, but also an SQL interface; this tutorial shows how to use both to retrieve Adobe Analytics data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Adobe Analytics. To access Adobe Analytics data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Adobe Analytics.

Once you have acquired the necessary connection properties, accessing Adobe Analytics data in PowerShell can be enabled in three steps.

Adobe Analytics uses the OAuth authentication standard. To authenticate using OAuth, you will need to create an app to obtain the OAuthClientId, OAuthClientSecret, and CallbackURL connection properties. See the "Getting Started" section of the help documentation for a guide.

Retrieving GlobalCompanyId

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.

Retrieving Report Suite Id

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.

PowerShell

  1. Install the module:

    Install-Module AdobeAnalyticsCmdlets
  2. Connect:

    $adobeanalytics = Connect-AdobeAnalytics -GlobalCompanyId "$GlobalCompanyId" -RSID "$RSID" -OAuthClientId "$OAuthClientId" -OauthClientSecret "$OauthClientSecret" -CallbackURL "$CallbackURL"
  3. Search for and retrieve data:

    $city = "Chapel Hill" $adsreport = Select-AdobeAnalytics -Connection $adobeanalytics -Table "AdsReport" -Where "City = `'$City`'" $adsreport

    You can also use the Invoke-AdobeAnalytics cmdlet to execute SQL commands:

    $adsreport = Invoke-AdobeAnalytics -Connection $adobeanalytics -Query 'SELECT * FROM AdsReport WHERE City = @City' -Params @{'@City'='Chapel Hill'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Adobe Analytics\lib\System.Data.CData.AdobeAnalytics.dll")
  2. Connect to Adobe Analytics:

    $conn= New-Object System.Data.CData.AdobeAnalytics.AdobeAnalyticsConnection("GlobalCompanyId=myGlobalCompanyId; RSID=myRSID; OAuthClientId=myOauthClientId; OauthClientSecret=myOAuthClientSecret; CallbackURL=myCallbackURL;") $conn.Open()
  3. Instantiate the AdobeAnalyticsDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT Page, PageViews from AdsReport" $da= New-Object System.Data.CData.AdobeAnalytics.AdobeAnalyticsDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.page $_.pageviews }