Purpose
This Google Apps script allows for calling the Alma Analytics API and retrieving one or more reports, data from which is then used to populate tabs in a given Google spreadsheet.
Setup
-
Clone the repo and/or download
analytics.js. -
Create or modify an existing Google Sheets document as follows:
a. Create a tab called
config.b. This sheet should have the following column headers:
-
apiKey
-
reportPath
-
spreadsheetTab
c. Include your API key from the Ex Libris Developer Network in the first row under the
apiKeycolumn.d. For each Alma Analytics report you wish to import, include the path to it in Analytics as a new row under the
reportPathcolumn. Each path must begin with the top-level folder. For example, a report saved in the IZ-shared folder for George Washington University, in a subfolder calledtop_textbookswould have this path:/shared/The George Washington University/top_textbooks/top_textbooks_order_data_by_title. The name of the report is the last part of the path.e. For each report, include the name of the tab in the current spreadsheet where you want the data to display as a new row under the
spreadsheetTabcolumn. (If the tab does not exist at import time, the script will create a new tab with that name. Any data in an existing tab will be overwritten.) Yourconfigtab should look as follows: -
-
Now open the Script Editor under the Tools menu in Sheets, and create a new project (following the relevant instructions here).
-
Select
New-->Scriptfrom theFilemenu, and paste in the code fromanalytics.js. -
Modify the line of code
var spreadsheet = SpreadsheetApp.openById('');to include the ID string of your Google Sheet. (The ID is the long identifier described on this page of the Google Sheets API documentation.) Make sure your spreadsheet ID is between the single quotes in this line of code. Then save the code by clicking the floppy disk icon. -
Now you should be able to run the script either by selecting the
mainfunction in the Script Editor console or by setting up a project trigger.
