Google Data Studio connectors to fetch data from PipeDrive API.
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.
- Go to Google Apps Script
- Create a new project
- Name it
- Go to project settings
- Check
Display appsscript.json manifest file
- Take note about Script ID (useful for children connectors)
- Go back to code window
- Create files and set code for Core connector
- Go to Google Apps Script
- Create a new project
- Name it
- Go to project settings
- Check
Display appsscript.json manifest file
- Go back to code window
- Create files and set code for the child connector
- In
appsscript.json
, changeDependencies
>Libraries
>LibraryID
to the Core script ID you took note - Deploy it (easiest by going through
Use old editor
button >Publish
>Publish from manifest file
)
- Go to Google Data Studio
- Create > Data source
- Search for your deployed child connector
- Fill credentials
- Now you can import it in your GDS reports
First, copy Deals or Pipelines connector.
Link to API, where you can find data for below steps.
Then you have 3 things to change :
- Change
endpoint
global var to API endpoint name : api/v1/deals?api_token=XXX
// core.gs
var endpoint = 'deals';
- 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;
}
- 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 };
});
}