One of the great features of Camlytics is webhooks support for any of the camera events types. For example, if you do people counting in two of your retail stores and you want to aggregate all counting data into one spreadsheet in the cloud for the simple access and custom charting - you can do that easily with Camlytics webhooks and Google Sheets.

To automate the submission of data into your Google Sheet, fill in the columns headers with parameter names (event-type, event-objectId, etc.) and click Tools > Script editor. You will be redirected to a Google Script page. Copy and paste the sample script below into the script editor.

You can get more information on how to set up the script here.

function doGet(e){
  return handleResponse(e);
}
// Usage
//  1. Enter sheet name where data is to be written below
        var SHEET_NAME = "Sheet1";
//  2. Run > setup
//
//  3. Publish > Deploy as web app 
//    - enter Project Version name and click 'Save New Version' 
//    - set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously) 
//
//  4. Copy the 'Current web app URL' and post this in your Camlytics webhook URL field
//
//  5. Insert column names on your destination sheet matching the parameter names of the data you are passing in (exactly matching case)
//
var SCRIPT_PROP = PropertiesService.getScriptProperties();
//
function handleResponse(e) {
  var lock = LockService.getPublicLock();
  lock.waitLock(1000);
  
  try {
    var doc = SpreadsheetApp.openById(SCRIPT_PROP.getProperty("key"));
    var sheet = doc.getSheetByName(SHEET_NAME);
    var headRow = 1;
    var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
    var nextRow = sheet.getLastRow() + 1;
    var row = []; 
    for (i in headers) {
        row.push(decodeURIComponent(e.parameter[headers[i]]));
    }
    sheet.getRange(nextRow, 1, 1, row.length).setValues([row]);
    return ContentService
          .createTextOutput(JSON.stringify({"result":"success", "row": nextRow}))
          .setMimeType(ContentService.MimeType.JSON);
  } catch(e){
    return ContentService
          .createTextOutput(JSON.stringify({"result":"error", "error": e}))
          .setMimeType(ContentService.MimeType.JSON);
  } finally {
    lock.releaseLock();
  }
}
//
function setup() {
    var doc = SpreadsheetApp.getActiveSpreadsheet();
    SCRIPT_PROP.setProperty("key", doc.getId());
}			

In the end you will receive the production script URL that you will insert into your Camlytics events setings in this format: https://script.google.com/macros/s/a-KfycbwRo7VDNXQSCjplDsj43Y7ev-XioFNvy_bQsNNnofPJ4-1bA52c67/exec

Example of output in the Google Sheet that you are going to receive when events are fired:

camlytics google sheets