- Notifications
You must be signed in to change notification settings - Fork9
R Client for Adobe Analytics API v2.0
License
Unknown, MIT licenses found
Licenses found
benrwoodard/adobeanalyticsr
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Connect to the Adobe Analytics API v2.0, which powers AnalysisWorkspace. The package was developed with the analyst in mind and willcontinue to be developed with the guiding principles of iterative,repeatable, timely analysis. New features are actively being developed,and we value your feedback and contribution to the process. Pleasesubmit bugs, questions, and enhancement requests asissues in thisGithubrepository.
A special thanks to our company,Further (formally SearchDiscovery), for giving us the time,encouragement, and support to build out this package. There is no waythis would have been possible without the opportunity to learn from andwork with some of the most amazing people in the analytics industry.
The Adobe Analytics v1.4 API, while on its way out, still has somefunctionality that is not (yet?) available in the v2.0 API. As such, theRSiteCatalyst package createdby Randy Zwitch remains a useful package. While this is not acomprehensive list, some of the features that are available throughRSiteCatalyst that are not available through the v2.0 API (and, byextension, are not available through this package) are:
- Data Warehouse queries
- Marketing Channel configuration and processing rules
- Some configuration details for variables (eVar, prop, events)
- Data Feed details
The v1.4 API also allows the user to pull data once they have webservices access set up for their account and the client ID and clientsecret that comes along with that. In other words, it doesnot requirethat an Adobe Console API project be created, whichis something thatis required to use the v2.0 API. The benefit of getting an Adobe ConsoleAPI project set up, though, is that the user then doesnot need webservices access set up on an account-by-account basis to pull data usingthe package if using the OAUTH authentication. If using the JWTauthentication method with v2.0 API, then a projectdoes need to becreated for each company account.
As a purely editorial side note, the creators and maintainers of thispackage would like to express their eternal gratitude to Randy for thework he put in to creating and maintainingRSiteCatalyst. His workbrought the power of R combined with data pulled directly via the AdobeAnalytics API to a global audience, and we can only hope (for ourselvesand the analyst community writ large) thatadobeanalyticsr can live upto the high standard he set with his work.
# Install from CRANinstall.packages('adobeanalyticsr')# Load the packagelibrary(adobeanalyticsr)# Install devtools from CRANinstall.packages("devtools")# Install adobeanayticsr from githubdevtools::install_github('benrwoodard/adobeanalyticsr') # Load the packagelibrary(adobeanalyticsr)There are four setup steps required to start accessing your AdobeAnalytics data. The following steps are each outlined in greater detailin the following sections:
- Create an Adobe Console API Project
- Create and add the OAuth or S2S arguments to your
.Renvironfile. - Set the type of authorization being used by calling
aw_auth_with(type = ""). Thetypevalue should beS2S oroauth - Get your authorization token using
aw_auth(). Once theauthorization type has been set (the previous step), this will lookfor.Renvironvariables and complete the authorization. - Get your
company_idby using the functionget_me().
If you are using the OAuth authorization, regardless of how manydifferent Adobe Analytics accounts you will be accessing, you only needa single Adobe Console API project (you will still need to have workinguser credentials for each account you want to access, but the AdobeConsole API project is just the way you then get access to authenticateusing those user credentials; yes…confusing!) If you are using the S2Sauthorization then you will need an Adobe Console API project createdfor each organization you will be accessing. The following steps willget you setup on either of the different authorizations:
- Navigate to the following URL:https://console.adobe.io/integrations.
- Click theCreate New Project button and selectEmpty Project
- Click theAdd API button.
- Select the Experience Cloud product icon and then chooseAdobeAnalytics and clickNext.
- The next series of steps depends on your choice of authorization.
- OAuth
- Select the OAuth option and then clickNext.
- SelectWeb as the platform where you want the integration.
- Add Default redirect URI
https://adobeanalyticsr.com/token_result.html*. - Add Redirect URI pattern
https://adobeanalyticsr\.com/token_result\.html*.
- S2S
- Select theServer-toServer options and then clickNext.
- Click on theFull CJA Access button.
- ClickSave configured API.
* This is simply a helper site we’ve set up in order to make it easierto generate a token. The site does not store any information.
Creating an Adobe Console API Project in under 60 seconds
This file is essential to keeping your information secure. It alsospeeds up analysis by limiting the number of arguments you need to addto every function call.
If you do not have an
.Renvironfile (if you have never heard ofthis file you almost certainly don’t have one!), then create a newfile and save it with the name.Renviron. You can do this fromwithin the RStudio environment and save the file either in yourHomedirectory (which is recommended; click on theHome buttonin the file navigator in RStudio and save it to that location)orwithin your project’s working directory.Get the following variables from the OAuth project and add them tothe file* (seeCreating an Adobe Console API Project above):
- (OAuth)
AW_CLIENT_ID– the client id found in the AdobeDeveloper Console - (OAuth)
AW_CLIENT_SECRET– the client secret key found in theAdobe Developer Console - (S2S)
AW_AUTH_FILE– The path of a JSON file containing fieldswith S2S authentication data. This file is downloaded by clickingClick on “OAuth Server-to-Server” under “CREDENTIALS” in the leftcolumn. Locate the “Download JSON” button on the top right andclick it to download the JSON file. Alternatively, you canmanually create this file by copying and pasting the Client ID,Client Secret (click “Retrieve client secret”), Technical AccountID, and Organization ID into a.jsonfile. Reference?cja_authfor more information on the variables needed. Using thepreconfigured JSON file is the easiest method.
- (OAuth)
(Optional) Add
AW_COMPANY_IDandAW_REPORTSUITE_IDvariablesonce you know them (how to find available values for these twovariables is described in step 4 below).
After adding these variables to the.Renviron file and saving it,restart your R session (Session > Restart R in RStudio) and reloadadobeanalyticsr (library(adobeanalyticsr)).
* The format of variables in the.Renviron file is straightforward.If you add all four of the variables above, they would simply each betheir own line in the file:
## If using OAuth AW_CLIENT_ID = "[OAuth client ID]"AW_CLIENT_SECRET = "[OAuth client secret]"AW_COMPANY_ID = "[Company ID]"AW_REPORTSUITE_ID = "[RSID]"## If using S2S AW_AUTH_FILE = "[auth_file.json]"AW_COMPANY_ID = "[Company ID]"AW_REPORTSUITE_ID = "[RSID]"An example authentication JSON file contains the following at a minimum:
{"API_KEY":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",#OAuth"Client_ID:"xxxxxxxxxxxxxx", #S2S Auth"CLIENT_SECRET":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx","SCOPES": ["xxx","xxx"],#S2S Auth"ORG_ID":"xxxxxxxxxxxxxxxxxxxxxxxx@AdobeOrg","TECHNICAL_ACCOUNT_ID":"xxxxxxxxxxxxxxxxxxxxxxxx@techacct.adobe.com"#OAuth}Other fields are simply ignored.Note:API_KEY means the samething asCLIENT_ID.
The token is actually a lonnnnng alphanumeric string that is the whatultimately enables you to access your data:
OAuth process OAuth requires an interactive environment (see step 3below), and the authentication token expires after 24 hours, which thenrequires repeating steps 2-9 below:
- In the console, enter
aw_auth_with('oauth')and pressEnter. - Enter
aw_auth()and pressEnter. - A browser window should appear that prompts you to log in to yourAdobe Marketing Cloud account.
- Log in.
- You will then be redirected to
adobeanalyticsr.com* and a screenthat displays your token.* - Copy the token (only).
- Return to the R console. You should see a prompt toEnterauthorization code:
- Paste the token you copied and pressEnter.
- You should see the confirmation message: “Successfully authenticatedwith OAuth”
As noted above, this token will expire every 24 hours, so you will haveto periodically repeat this step.
* Again, this is simply a helper site I’ve set up in order to make iteasier to generate a token. The site does not store any information.
S2S process S2S doesnot require an interactive environment anddoes not require a token refresh every 24 hours, but it does require abit more work to set up initially (as described above). To authenticateusing S2S:
- In the console, enter
aw_auth_with('s2s')and pressEnter. - Enter
aw_auth()and pressEnter. - You should see the confirmation message: “Successfully authenticatedwith S2S: access token valid until…”
JWT processdeprecated as of June 30, 2025 JWT doesnot requirean interactive environment and does not require a token refresh every 24hours, but it does require a bit more work to set up initially (asdescribed above). To authenticate using JWT:
- In the console, enter
aw_auth_with('jwt')and pressEnter. - Enter
aw_auth()and pressEnter. - You should see the confirmation message: “Successfully authenticatedwith JWT: access token valid until…”
The last step is to get yourcompany_id (or, if you have access tomultiple accounts, get thecompany_id you want to work with). This isalso an excellent way to confirm that everything is set up correctly:
- In the console, type
get_me()and pressEnter. - You should then see a list of all of the companies you have accessto. TheglobalCompanyId value is what you will use to specifythe company that you want to access. If you are working solely (orprimarily) with one company, then consider adding the
company_idasAW_COMPANY_IDin your.Renvironfile as described in step 2above. Otherwise, you can specify it within each function call thatrequires it. - If you will be working solely (or primarily) with a single reportsuite, then consider adding the report suite ID (RSID) as
AW_REPORTSUITE_IDin your file as described in step 2 above. Youcan retrieve all of the report suite IDs for a givencompany_idusing the functionaw_get_reportsuites(company_id = '[the company ID for account of interest]').
If you added any values to your.Renviron file (and then saved it!),then restart your R session (Session > Restart R in RStudio) andreloadadobeanalyticsr (library(adobeanalyticsr)).
You now should be set to start pulling data, typically starting withaw_get_metrics() andaw_get_dimensions() to get a list of availabledimension and metric IDs, and thenaw_freeform_table() to pull somedata!
About
R Client for Adobe Analytics API v2.0
Resources
License
Unknown, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors6
Uh oh!
There was an error while loading.Please reload this page.
