Automatically track email signups using Google Scripts, Zapier, and Mailchimp

Tracking Kpis - Where to begin


Tracking KPIs (Key Performance Indicators) on a regular basis is a very important part of execution in every startup. However, tracking them manually can be time consuming, prone to error, and difficult to keep current figures up to date in real-time. This can lead to a lax approach to tracking KPIs, and sometimes it can be difficult to get everyone in your team to take them seriously.

One solution is to use softwares and suites to aggregate your data - downside there is that they’re often costly, and unnecessarily complex and in-depth for what is required at an early stage startup. 

Instead, we’ve found it far more effective to create a spreadsheet that's fully customized to only track the KPIs that you need at any given time, and that's setup so you can add more as you scale. Ofcourse, once you outgrow the spreadsheet, you can easily transition to an enterprise analytics SaaS.

(And since I’m a spreadsheet wiz, and have published entire courses on spreadsheets, I just couldn’t resist…)

What we’re about to build

A rather hardcore, completely automated google spreadsheet that:

1. Uses custom embedded mailchimp signup forms to collect email signups from 2 separate landing pages

2. Uses Zapier to push the email signups to the spreadsheet

3. Calculates KPI progress and produces basic analysis and charts

And finally

4. Uses google scripts to Send an automated email out to the entire team when a KPI has been achieved - (even when the spreadsheet is closed).

Which means you simply have to set the KPI for the week or month - and the spreadsheet takes care of the rest.




….and because you can customize it with zapier to track many more KPIs - including Twitter followers, facebook likes, even user signups from a database etc …




Before you begin


There is indeed some coding involved in the google script & mailchimp integration, but if you don’t have coding experience don’t fret - I’ve given you all the code snippets I wrote - which you can just copy and paste.

If you'd like the full experience, I made a short, completely FREE video course which includes the full build of the spreadsheet, and takes you through all the formulas. so go for your life!


Step 1 - Landing Pages : KPI Tracker 1 - set up blogger

First up, we’ll create 2 landing pages to test the spreadsheet and mailchimp integration. If you already have custom landing pages set-up, just skip to Step 2.  Otherwise, the quickest way to do this is to use blogger - which you already have access to if you have a gmail account. If not create one. 

Head over to your blogger account or create one (

Go to My Blogs.

Create a new blog with “Landing page 1” in the title

Create a new page and open edit mode.

Leave this page open for now, and open blogger again in a new window.

Create another new blog - this time with Landing Page 2 in the title.

Then create a new page in that one, open in edit mode and leave this page open as well.   


Step 2 - Mailchimp Embed KPI Tracker : 2 - Signup Forms

Open mailchimp (create an account at and a create new list

Mailchimp - very cool-y - allows you to track where signups to an email list originate from across multiple landing pages. Doing so requires a small hack to the embed code.
(NOTE: this only works for embedded mailchimp signup forms)

Create a mailchimp list -  name it anything you like!

Go to the Lists page (

Click on the dropdown menu and select Signup forms

Choose General Forms KPI Tracker : 3 - Add text field

Go to the Build it tab

Click on Add a field tab and click Text

In Field settings, add the following

Field label : Signup Location

Field tag: SIGNUP

Then choose the hidden option in the visibility section

Save the field KPI Tracker : 5 - Find Form Action

Next to save time, press CTRL+F or CMD+F and lookup the phrase “form action” (all lower case).

Now you should have located a line of code that looks similar to this:

[cc lang="html"]
form action=”//

At the very end of that line, insert the following:

[cc lang="html"]
&(field label name)=(the name of the landing page your tracking)

So for example: The field name you set was SIGNUP, and the name of the landing page your tracking can be anything - lets say landingpage1

Therefore you would write:

[cc lang="html"]

And when you add that to the code it should look like this:

[cc lang="html"]
form action=”//

Great - now that done - copy the whole embed code - and leave the text editor open for now.

Then go back to your first blogger landing page you opened earlier.

Click the HTML tab

And paste the code in without altering anything.

Click update.

Now go back to the text editor.

Change the code you edited from landingpage1 to landingpage2.

Then copy all the code again.

Open your second blogger page, paste into the html section, then save.

Great - now you have 2 separate landing pages with unique embedded mailchimp signup forms

Next up - let’s get this spreadsheet happening.



Step 3 - Setup Spreadsheet

The spreadsheet template I created is quite detailed and complex - so to save time (like a lot of time!), start by opening it below.


Then go to File -> Make a copy


Now you have your own copy of this powerful little template in googledrive to customize for yourself.

Take a minute to become acquainted to how I’ve set up the dashboard and blog subscription sheets - which are main ones you’ll use.

The blog subscription sheet is a template for a task (for which you want to track KPIs). To create a new task just duplicate this sheet, rename it to be the task you wish to track, then add the necessary components to the dashboard sheet. 

(If you need help at this stage or have any questions just leave comments at the bottom of the post or twitter me @dannyblaker! Alternatively find on Slack)

Now - time to get our sheet ready for the Zapier API


In the LSCHAT Demo Sheet, click on the Incoming Subscribers LIVE ZAPIER work sheet (at the bottom)

Now delete all the entries in every row except the first 2 rows. (The reason is 1. because we want to start with a clean slate, and 2. Zapier requires one line of demo entries to match against the mailchimp fields)

K that done - time to watch Zapier wield the mailchimp API like Zeus.



Step 4 - Zapier Integration KPI Tracker : 6 - Zapier P1

Go to, and create a Zapier account (if you don’t have one yet).

Go to My Zaps

Make a Zap

Set trigger app as Mailchimp

Select New Subscriber as your Mailchimp Trigger

Select your mailchimp account

Select the Mailchimp List we created way back in Step 1 (The same one you used to get the embed code)

Read through the “Things to double check list”.

Proceed to test. KPI Tracker : 7 - Zapier P2

Next Choose Google Sheets as your Action App

Choose create a Spreadsheet Row for your google sheet action

Connect your google sheets (google) account.

Next Select your target Spreadsheet

And then the worksheet within it that will be the destination sheet for all the mailchimp subscribers (select the “Incomming Subscribers (DONT TOUCH)” worksheet) KPI Tracker : 8 - Zapier P3

Add the following fields (making sure they’re matched to the right field entries):

1Merges  FNAME
1Merges  SIGNUP
1Merges  LNAME

Proceed to the Testing phase - Once “Test Successful” pops up click Finish

Done. Zapier will now push all new subscribers for mailchimp list to your google sheet so you can begin tracking KPIs.



Step 5 - Automated email notifications (Google script)

Go back to your spreadsheet

Navigate to the worksheet “KPIemailer”

In the first entry cell of the email column (A2) , add the email address that you’d like to send notifications to

(to add multiple emails just separate each one with a comma).

Now drag and copy the cell down to the final row with entries in it - which is in this case row 31

Customize the message you’d like to send for each KPI in column B - or just leave them as they are. KPI Tracker : 9 - Google Scripts

Open the script editor by going to Tools -> Script editor

Rename the default script “EmailSender”

Copy and paste the code below.

[cc lang="js"]
// This first variable is going to be used when
// we're ticking off which KPI emails have already been sent.

function sendEmails2() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("KPIemailer");
var startRow = 2; // Chooses the first row of data to begin looking through
var numRows = 30; // Specifies the number of rows to look through
var dataRange = sheet.getRange(startRow, 1, numRows, 30) // Fetch the range of cells A2:E31
var data = dataRange.getValues(); // Fetch values for each row in the Range.
for (var i = 0; i < data.length; ++i) { // create a for loop that will search through all the rows consequtively until it reaches the end of the data range - which you have already specified in the line above
var row = data[i]; // attach the data loop reference to a new variable called "row"
var emailAddress = row[0]; // First column
var message = row[1]; // Second column
var emailSent = row[2]; // Third column
var result = row[3]; // Forth Column
if (emailSent != EMAIL_SENT && result == "NONE") { // An If statement that prevents sending duplicate emails by checking 2 conditions. If both conditions are met, then it will proceed to the following line.
var subject = "KPI has been demolished"; // the message that will appear as the subject line in the email that is sent.
MailApp.sendEmail(emailAddress, subject, message); // Send an email with the email address, subject and message specified in respective column from each row of the data range
sheet.getRange(startRow + i, 3).setValue(EMAIL_SENT); // Once an email has been sent - this will label the respective cell in column C as "EMAIL_SENT"
SpreadsheetApp.flush(); // I've put this here so it updates the cell immediately incase the script is interrupted


Optional step: Customize the email subject how you desire -  located on line 20 of your code.

Go to Resources -> Current project triggers

Add a new trigger

Select SendEmails2 (should be only option)

Then Under events select From Spreadsheet and run the event On change

Hit done

Run the script (click the play icon up the top)

NOTE if you encounter any errors and are unsure what the problem is, post a copy of your code - along with your error message - either in the comments below, or go to LSChat Slack => Blog post questions channel, and post your code as a code snippet along with the error (recommended). 

And that’s it - you should now receive email notifications each time you reach a KPI that you’ve set in the spreadsheet. 


How to Set a KPI

To set a KPI, go to the Blog Subscription template worksheet, then add a Kpi to any given week in Row 3.

How to Set the Starting Date

To set the starting date go to the BACKEND worksheet and alter the date in F2

I hope you've found this post useful! If you have any ideas you’d like us to explore re KPI tracking or anything else, head over to LSChat Slack and let us know! Cheers!

If you haven't joined our community of lean startup enthusiasts, you can do so via the link below


And once again - If you're overwhelmed at all, or want more clarification for any of the steps, or would simply prefer a video tutorial - I highly recommend taking my course below :)


Danny Baker

Danny has a wealth of experience in the start-up and technology sectors spanning over 10 years, and is the founder and co-founder of numerous companies and initiatives, such as Unudge, & Geartooth.

Danny's diverse skill set encompasses disruptive marketing strategy, business strategy, product design, audio production, data analysis (R, R Markdown, Python), graphics design (photoshop, Indesign, Illustrator), communications, social media marketing, project management, growth strategy, UX design, front-end web development (WP, Joomla, JS, Python, HTML, CSS), and corporate law.

Danny is also a spreadsheet expert and an online instructor, teaching at His courses have amassed over 11,000 students to date.

He also blogs regularly – you can find his posts at

You can reach Danny on twitter @DannyBlaker