Add Projects Listed on Google Spreadsheets to Toggl

Share on facebook
Share on twitter
Share on pinterest

Summary: Do you have many Toggl workspaces and want to add the same projects to all? We created a Google spreadsheet file in which you can list all you projects. Once you click the button, all project names are automatically added to your listed workspaces.

In order to have good performance in each of your projects, it will be so helpful to track the time you spend to finish them. The lower time you assign to projects, the more projects you can manage. So we need a software to do us this favor. Toggl is a time tracking software that allows you to track your activities. Time tracking software such as Toggl is widely used by many companies mainly because it provides detailed insight into company’s or project’s status. It is awesome since you can integrate Excel Spreadsheet in google platform to toggle. This integration makes work easier, faster, and more convenient.

Integrations with google spreadsheets are so helpful especially in project management. Using the script we have written, projects managers can add projects to many workspace and assign them to different employees just by one click. The only thing you need to do this is using your API token (you can find it in your toggl profile) and workspaces ID. In the sample file we have prepared, there are 2 worksheets. First of all you should put your API token in Config sheet.

Google Spreadsheet and Toggl integration, entering API token in the Config sheet

you can put your workspace ID in first column and your projects names to fourth row in “psheet”. Then to add a project to a workspace, simply check mark their intersection. Finally click on Send Projects to Toggl button.

Google Spreadsheet and Toggl integration, Adding Workplace ID and Project name and clicking on the “Send Projects to Toggl” button.

This workbook has a script function “sendDataToToggl()” that handle this integration.

function sendDataToToggl()
  //counter will be used for counting added projects.
  var counter=0;
  //define variables for worksheets and necessary data
  var spreadSheet = SpreadsheetApp.getActiveSpreadsheet();
  var sht_config = 'Config';
  var sht_psheet = 'psheet';
  var configsheet = spreadSheet.getSheetByName(sht_config);
  var psheet = spreadSheet.getSheetByName(sht_psheet);
  var cfgdata = configsheet.getDataRange().getValues();
  var psheetdata = psheet.getDataRange().getValues();
  var apiToken = cfgdata[1][1];
  var unamepass = apiToken + ":api_token";
  var digest = Utilities.base64Encode(unamepass);
  var lastWorkSpace = psheet.getLastRow();
  var lastProject = psheet.getLastColumn();
  //connect to toggl api and send projects
  var digestfull = "Basic " + digest;
  var url = "";
  for (i = 1; i < lastWorkSpace; i++)
        var wid = psheetdata[i][0];
        for (j=2; j < lastProject; j++)
              var pname = psheetdata[3][j];
              var data = {"project":{"name":pname,"wid":wid,"template_id":1793088}};
              var options = {
                              "contentType": "application/json",
                              "method": "post",
                              "headers": {"Authorization": digestfull},
                              "payload": JSON.stringify(data)
                  try { var response = UrlFetchApp.fetch(url, options);counter=counter+1} catch (e) {}
  Browser.msgBox(counter+"  New projects successfully added")

By this instruction, managing your projects become easier than before. The best point of it is to save your time while managing a project, since you will be able to use your spreadsheets directly into the Toggl software.

To use this solution, open this Google Sheet and make a copy in your Google Drive account.

  • To figure out your workspace_id: go to Team in The number at the end of the URL is the workspace id.
  • To figure out your api_token: go to your Profile in, your API token is at the bottom of the page.


Subscribe to our Newsletter

Share this post with your friends

Share on facebook
Share on google
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *