Chiogros / PipeDrive-connectors-for-GDataStudio

A set of connectors for Google Data Studio to fetch data from PipeDrive API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PipeDrive connectors for GDataStudio

Google Data Studio connectors to fetch data from PipeDrive API.

Connectors organization

There is a main connector called Core: it retrieves and handles data to bring it properly for GDS and it sets the authentication method. Children connectors (Deals, Pipelines, ...) use Core functions and also have specific functions for their API endpoint.

How to use them on GDS

Setup Core connector

  1. Go to Google Apps Script
  2. Create a new project
  3. Name it
  4. Go to project settings
  5. Check Display appsscript.json manifest file
  6. Take note about Script ID (useful for children connectors)
  7. Go back to code window
  8. Create files and set code for Core connector

Setup child connector

  1. Go to Google Apps Script
  2. Create a new project
  3. Name it
  4. Go to project settings
  5. Check Display appsscript.json manifest file
  6. Go back to code window
  7. Create files and set code for the child connector
  8. In appsscript.json, change Dependencies > Libraries > LibraryID to the Core script ID you took note
  9. Deploy it (easiest by going through Use old editor button > Publish > Publish from manifest file)

Use connectors in GDS

  1. Go to Google Data Studio
  2. Create > Data source
  3. Search for your deployed child connector
  4. Fill credentials
  5. Now you can import it in your GDS reports

To create a new PipeDrive connector

First, copy Deals or Pipelines connector.

Link to API, where you can find data for below steps.

Then you have 3 things to change :

  1. Change endpoint global var to API endpoint name : api/v1/deals?api_token=XXX
// core.gs
var endpoint = 'deals';
  1. Put fetchable fields from API
// fields.gs
function getFields(request) {
  var fields = cc.getFields();
  var types = cc.FieldType;
  var aggregations = cc.AggregationType;

  fields.newDimension()
    .setId('Deals_FieldName_example')
    .setType(types.NUMBER); // BOOLEAN, TEXT, ...
    
  fields.newDimension()
    .setId('Deals_X')
    .setType(types.TEXT); // BOOLEAN, NUMBER, ...
  
  // put all fetchable fields
  
  return fields;
}
  1. Handle each data row
// dataHandler.gs
function responseToRows(requestedFields, response) {

  // Filter for requested fields
  var fields = requestedFields.asArray();

  return response.map(function(dataElement) {
    var rows = [];
    
    fields.forEach(function (field) {

      switch (field.getId()) {
        case 'Deals_FieldName_example':
          return rows.push(dataElement.FieldName_example);
        case 'Deals_X':
          return rows.push(dataElement.X);
        // put all other cases
        default:
          break;
      }
    });

    return { values: rows };
  });
}

About

A set of connectors for Google Data Studio to fetch data from PipeDrive API.

License:GNU Affero General Public License v3.0


Languages

Language:JavaScript 100.0%