How to Build a Data Studio Community Connector

How to Build a Data Studio Community Connector

Data Studio Community Connectors are community developed connectors that enable access to a variety of data sources directly from within data studio. Using a Community Connector, we can pull in data and use them in our reports and dashboards. A Connector can pull in data from sources like social media platforms, search engines, advertisements statistics, public or open data sets, private company data, and any source of data which can be accessed using Apps Script.

In this blog post we will be learning how to create a Currency Exchange Rates Community Connector from scratch.

 

Prerequisites:

  1. Get the API Key for the source (if required). We will be using API from Fixer.io which has a public API so we do not need an API Key
  2. Request Developer Access from Google to deploy Community Connector. This may take few hours but without having Developer Access, we can’t deploy the connector.

 

Step 1: Setup Apps Script

Visit Google Apps Script. This is a scripting tool where we will be writing our code. Create a new Project. Delete everything from Code.gs file.

 

Step 2:  Create Skeleton

Next we will create the skeleton of the connector. Every connector has 4 required functions.

  1. getConfig() // For any user defined configs

  2. getSchema() // To get the schema for any request

  3. getData() // Fetch and return data for any request

  4. getAuthType() // Identify the authentication method

create connector skelton

Step 3: Defining Configs getDate()

We will define our configurations in the getConfig function of the connector. We can have multiple configurations as per our needs. For our connector, we will display an information message and ask for base and interesting currencies of the users. We can take user’s input in the form of text, multiline text, single and multiple select.  Our configuration looks like this:

define configuration

Step 3: Defining Schema getSchema()

We will define our data schema for any given request in the getSchema function of the connector. This is typically an array of objects. We can also make use of the inputs from users which will be available in the request.configParams property which we will get as the parameter of this function. As per your requirements, the schema can be fixed or may be provided dynamically at the request time.

define data schema
get schema

Step 4: Fetch the data getData()

This is a function where we will make our API call and fetch the data from any given source. Once the data has been fetched, we will configure or parse it according to the schema and return it back in an object form with the schema.

fetch data
fetch data with urlfetchapp

Step 5: Setup authentication

This is a function where we will define our authentication, if any. In our connector we do not need any authentication so we return ‘NONE’ here:

define authentication

Few Notes:

  1. Apps Script does not support ES6 as of now
  2. Field name can’t contain - or _ in the schema
  3. Names of four key functions must be as they have been described above

Step 6: Complete the project manifest

Click on View > Show manifest file to open it. Please note that you need Developer Access to see this option in apps script. Add the name and other details to your manifest file and save it. Required fields are  name, logoUrl, company, companyURL, addonURL, supportURL, and description.

complete manifest

Step 7: Deploy the connector

Save your Apps Script project. Click on Publish > Manage Deployments. The click on Get ID and open the link.

deploy connector

Step 8: Use the connector in Data Studio

Configure the connector by providing the necessary fields. Grant authorization and then click Connect on the top right corner.

Complete code for this connector is available here: https://goo.gl/r1W3df


Google Data Studio Community Connector a powerful tool to pull the data in desired form and then be displayed in the form of reports, or dashboards using Data Studio. Here is how we built our first community connector for project management data.

 

Related Posts:

  1. Data Studio Connectors: Why & How to Use
  2. Google Data Studio Tutorial for Beginners & Novices
  3. Free Google DataStudio Template for Content Marketers

 

Sohaib Nehal

I am Sohaib Nehal. Professionally a Full Stack software developer. Passionate about travelling, meeting new people, trying new food and discussing unique ideas.