Have you ever tried to set up a Marketo Google Sheets Integration but have been frustrated by the need to use a 3rd party middleman like Zapier? Well, today I am going to show you a very cool and easy way that you can send Marketo data directly to a Google Sheet using a webhook and all in under 15 minutes!
The first thing we are going to do is create the Google sheet where we want to log our Marketo data. In this example our sheet is going to contain 6 columns for each person who registers for our webinar:
Next, we are going to go to Extensions > Apps Script and paste the code below into a new script. Make sure to swap in the name of the sheet you want to log to in this script.
Note that the logic used in this script is pretty simple, it loops through the items in the webhook payload and puts them one by one into the columns within a row. This means that the first field in your webhook payload will go in the first column, the second field in the second column and so on.
Unless you make the logic smarter in this script you will need to structure the payload of your webhook so that the fields are in the order you want them to appear in a row.
function doPost(e) { // Specify the name of the sheet (tab) you want to log data to var sheetName = 'YourSheetName'; // Replace 'YourSheetName' with the actual name of your sheet // Get the spreadsheet and the specific sheet (tab) var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName); // Check if the sheet exists if (!sheet) { return ContentService.createTextOutput("Sheet not found"); } // Parse the incoming POST data var params = JSON.parse(e.postData.contents); // Create an array to hold the row data var row = []; for (var key in params) { if (params.hasOwnProperty(key)) { row.push(params[key]); } } // Append the row data to the sheet sheet.appendRow(row); // Return a success response return ContentService.createTextOutput("Success"); }
Then to deploy this Google Apps script so it is ready to catch our webhooks from Marketo we will:
Now that we have deployed this Apps script successfully we will complete our Marketo Google Sheets integration by creating a webhook to send our desired information to the URL that we just copied.
If it is your first time using webhooks in Marketo or you already have experience with them but want to see cool use cases then I recommend checking out the Webhook Quick Start Guide.
Now to create our Google Sheets webhook in Marketo:
{ "timestamp": "{{system.dateTime}}", "leadId": "https://app-xxxx.marketo.com/leadDatabase/loadLeadDetail?leadId={{lead.Id}}", "firstName": "{{lead.First Name}}", "lastName": "{{lead.Last Name}}", "company": "{{company.Company Name}}", "email": "{{lead.Email Address}}" }
Now that our Marketo Google Sheets integration is complete all we have to do to log our Marketo data to a Google sheet is to call the webhook from the flow of a smart campaign. In this example, we are going to put the "Call Webhook" action in the flow of our smart campaign that triggers whenever anyone registers for our webinar.
You will notice that I also included a "Campaign is Requested" trigger alongside the "Fills Out Form" trigger. This is to make testing the webhook easier so that if we want to trigger the webhook for a test person we can simply:
For the next webinar, you have you can either:
If you have webinars in succession then you will only need 1 webhook pointing to one deployment URL to log your webinar registrants. If you have concurrent webinars then you will need multiple webhooks to send to the multiple deployment URLs of the sheets that you want to log to.
And there you have it, that is how easy it is to integrate Marketo with Google Sheets to start logging data from your smart campaigns.
Next up you can take a deep dive into more use cases for Marketo webhooks and tokens:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.