With the amount of data being collected and the number of tasks to be completed for this data increasing, the ability to iterate and perform actions for each row in a dataset is vitally important for the marketing operations lead. This post will show you how to use a Zapier loop action to loop through and update rows of a Google sheet to give you a solid foundation that you can then build upon in your own Zaps.
For this post, we will use an example customer database in Google Sheets containing the “First Name”, “Order #”, “Email Address”, “Phone Number”, and “Delivery Date” of each customer. The “Delivery Today?” field is a checkbox field, which indicates whether the customer’s order will be delivered today.
We will use a Zapier loop action to compare today’s date to the “Delivery Date” value for every customer to set this “Delivery Today?” field to either be TRUE or FALSE. As shown in the second image below, we will use the “Schedule by Zapier” app to trigger this zap to run every day so that the “Delivery Today?” column is always up to date.
Database of customer information
Trigger to run the Zapier loop action every day
Zapier Loop Action Workflow
Zapier loop action overview
Zapier Loop Action Setup
The “Create loop from numbers” action event from the “Looping by Zapier” app is used to loop through each of the rows in the customer database. Since the first row of the Google Sheet is the header and we want to loop through every row, we will set the “Loop Iteration Counter Start” to 2 and the “Loop Iteration Counter Increment Amount” to 1.
With these 2 parameters set and taking into account Zapier’s 500 loop iterations restriction that means the maximum value we can set the “Loop Iteration Counter End” to is 501. If you have more than 500 rows of data that you need to update then you will need to use nested looping in Zapier (see theZapier For Each Loop Quick-Start Guide).
Zapier loop action configuration
Get Google Sheet Row
Once the Zap has been triggered, the first step is to obtain the “Delivery Date” value for the customer in a row. To do this the “Get Many Spreadsheet Rows” action from the Google Sheets app is used to pull in 1 row at a time from columns A to F. The “Loop Iteration” value from the Zapier loop action is used in the “First Row” field so that each row of the sheet will successively be accessed with each iteration of the loop.
If you want to see how to use the “Get Many Spreadsheet Rows” action to pull in multiple rows at once and how to transform the output to be used in subsequent actions then take a look at the How to use Zapier with Google Sheets post. Alternatively, take a peek at theZapier Google Sheets Quick-Start Guidefor more general guidance on the best option to import data from Google Sheets depending on the number of rows or the amount of data you want to import.
Get row from Google Sheet
Python Code
Next, we will use a few lines of Python code to determine whether today’s date matches the “Delivery Date” for this customer. Since the “Delivery Date” column in the Google Sheet is in dd/mm/yyyy format, the “Date Month, “Date Day”, and “Date Year” output from the “Schedule by Zapier” trigger are joined together using the “/” character so that we can get today’s date in the same format.
The Python code then splits the string output from the “Get Many Spreadsheet Rows” action into an array using the “,” character as a delimiter and accesses the 5th column of this array to get the customer’s “Delivery Date” value (P.S. array indexing starts at 0 in Python which is why we use array[4] instead of array[5] below).
Then a conditional logic statement is used to set the delivered_today variable to TRUE or FALSE depending on whether today’s date equals the “Delivery Date” value for this customer.
The final step involves using the “Update Spreadsheet Row in Google Sheets” action to set the “Delivery Today?” field equal to the “Delivered Today” output from the Python code in Step 4. Notice again how the “Loop Iteration” output from the Zapier loop action is used to specify which row in the Google Sheet should be updated.
Update row from Google Sheet
What’s Next?
Now that you have gotten a taste of looping in Zapier there might be a few more things that you are interested in doing now:
Want to import all those customers with deliveries today into Zapier and do something like send them delivery notifications? Then take a look at theZapier Loop Through Array from Google Sheets post.
Want to update more than 500 rows at once? Then take a look at theZapier For Each Loop Quick-Start Guide to see how you can use nested loops in Zapier to iterate to your heart’s content.
About The Author — Tyron Pretorius
Greetings fellow MOPs pros! As a previous mechanical engineer turned marketing operations lead, I now fancy myself as a full-stack marketer capable of designing websites, writing SEO-optimized content, and doing all the tracking and automation on the backend.
That being said my bread and butter is marketing operations and I love to get down and dirty with the Marketo API, Python, Zapier, and Google Scripts.
Integrating Google Sheets with Zapier will allow you to unlock a whole new array of automation possibilities for the data in your spreadsheets. This post will show you how to use Zapier with Google Sheets by walking through the 3 different options for importing data into Zapier using the Google Sheets app.
When trying to pull a specific row from your Google Sheet into Zapier you can use a lookup value dynamically populated with a variable from a previous step. This is useful but the real power of using the Google Sheets lookup value in Zapier comes when you need to import large amounts of data into your zap.
Anyone who has worked with Google Sheets in Zapier is likely to have run into the issue of needing to import more than the 20-row maximum imposed when using the Google Sheets app. This post will show you how to overcome this limitation and import multiple rows from Google Sheets into Zapier using some JavaScript and webhooks.