Eventbrite’s native reporting has much to be desired, and manually exporting data to feed into reporting is tedious and error-prone. Luckily, with a little code in Google Sheets, we can have data extract daily, so your data studio dashboards can consume the data. In this post, we’ll cover off how we can do this with Google Apps Script.
Step 1 – API Key
The first thing you’ll need to do is get your Eventbrite API Keys. Which you can do by visiting this page and signing in. (They refer to them as tokens some places)
https://www.eventbrite.com.au/platform/api-keys
For reference, you can also have a browse of the API documentation. It’s thorough and there is also an API explorer you can use to navigate fields.
Step 2 – Prep your Google Sheet
Create a brand new google sheet, or create a new tab on an existing sheet. Then name a sheet “Events” and leave it completely blank, we’ll fill it out next.
Step 3 – Add the Apps Script Code
To add apps script code into a Google Doc, you’ll need to open the script editor. You can find it under “Tools” -> “Script Editor”. Add the following code into the script editor.
Make sure you enter you API key with the token from step 1. And find an organisation ID to which you want to filter. In this example, we’re using the List Events function, but there are a tonne of functions available for you to use that can do a range of things.
function getEvents() {
// Make a POST request with a JSON payload.
var token = '/* Enter you API key*/';
var organization_id = '/* Enter an organisation ID */';
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Events");
sheet.clear(); // Clear data in Spreadsheet
sheet.appendRow(["EventID","EventName"]);
var options = {
'method' : 'get',
'contentType': 'application/json',
'headers' : {'Authorization': 'Bearer ' + token }
};
var events = UrlFetchApp.fetch('https://www.eventbriteapi.com/v3/organizations/'+ organization_id +'/events/', options);
// documentation on this API can be found here.
// https://www.eventbrite.com/platform/api#/reference/event/list/list-events-by-organization
var eventsJson = JSON.parse(events);
var eventsArray = eventsJson.events;
for (i=0; i<eventsArray.length; i++) {
var row = [
eventsArray[i].id,
eventsArray[i].name.text]
sheet.appendRow(row);
}
}
Once you’ve saved the changes, it should look something like this.
From here, you can test it by “Run” -> “Run Function” -> “getEvents”. If it works, you’ll see a list of events appearing in your Google sheet. Great! if not, something’s gone wrong.
Once you’re happy with the results, you can schedule this function to run daily, or hourly even. Go to “Edit” -> “Current Project’s Trigger” and add a new trigger for the function.
Summary
What’s happening in the background is Google is provisioning a new Google Cloud Platform project, setting up all the functions and infrastructure for you to do this. All free! Amazing, but true.