Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

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

License

Notifications You must be signed in to change notification settings

Chiogros/LinkedIn-connectors-for-GDataStudio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkedIn connectors for GDataStudio

Google Data Studio connectors to fetch data from LinkedIn Marketing API.

Connectors organization

There is a main connector called Core: it retrieves and handles data to bring it properly for GDS and it also sets the authentication method. Children connectors (like Company-followers) use Core functions and use specific functions they have 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

Get access token

  1. Create a LinkedIn developer account
  2. Create an LinkedIn app
  3. When you're on your app overview, go to Products tab and add Marketing Developer Platform product
  4. Go to Auth tab and set an Authorized redirect URLs for your app like https://access_token. It will be useful to get back your access token
  5. Take note of the Client ID and Client secret codes
  6. Execute this request to get a first token. You have to set client_id ; if needed you could change scope and change redirect_url to another redirect URL (that URL must match with the one set though step 4, and it must be encoded)
  7. Execute this to get a 60 days token. You have to change code to the token you got step 6, set client_id and client_secret. If needed, change redirect_url like step 6
  8. Use the latter token to fill connector credentials

How to create a new LinkedIn connector

First, copy Company-followers connector as template.

You can find the Marketing product documentation here.

Then you have 3 things to change:

  1. Change endpoint global var to the GET method you want and the parameters.
// core.gs
var endpoint = ['networkSizes/urn:li:organization:', '?edgeType=CompanyFollowedByMember'];
  1. Put fetchable fields from API
// fields.gs
function getFields(request) {
  var fields = cc.getFields();
  var types = cc.FieldType;
  var aggregations = cc.AggregationType;

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

  var rows = new Array();

  var fields = requestedFields.asArray();
  
  // Filter for requested fields
  fields.forEach(function (field) {
    
    switch (field.getId()) {
      case 'LinkedIn_JSON_index_name':
        rows.push(response.JSON_index_name);
        break;
      default:
        break;
    }
  });

  return rows.map(function(row) {
    return { values: [row] };
  });
  
}

About

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

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project