Zapier Loop Through Array from Google Sheets

Have large amounts of data in Google Sheets that you need to loop through but you’re not sure what is the best way import the data and then act on it? Then you’ve come to the right place! This post will show you how to use Zapier to loop through arrays imported from Google Sheets so that you can carry out actions in bulk for each of the array values as shown in the flow diagram below.

Flow diagram of the Zapier loop through array workflow
Flow diagram showing how to loop through array values in Zapier

Get Text Arrays from Google Sheets

In this post we’ll use the Customer Database Google Sheet to send delivery notifications to customers if their order is scheduled for delivery today. As explained in the Zapier Google Sheets Quick-Start Guide, there are a few different ways to import data from Google Sheets into Zapier as arrays depending on the number of rows or the amount of data you are importing.

For this example, we will use a webhook to send the arrays from Google Sheets to Zapier as explained in the Zapier Import Multiple Rows from Google Sheets post. Then in our zap, we will use the “Catch Hook” trigger to receive the incoming webhook containing the array information.

Customer database Google Sheet with button to send array values to Zapier using a webhook
Customer database Google Sheet with button to send array values to Zapier via webhook
The "Catch Hook" trigger used to receive the webhook from Google Sheets containing the arrays to be looped through in Zapier
Pull in the text arrays from the webhook sent from Google Sheets

Zapier Loop Through Array Workflow

Overview of the Zapier loop through array workflow
Zapier loop through array workflow

Zapier Loop Through Array Action

Once the incoming array information has been received, it can then be used in the “Set up action” section of the “Create Loop from Text” action in the “Looping by Zapier” app. In the “Values To Loop” section, you can create a looping variable for each of your arrays and then specify the “Text Delimiter” so that Zapier can parse out all the array values to loop through.

N.B. One thing to bear in mind is that the maximum number of loop iterations that you can do using this loop through array action is 500. If you have more iterations to do than this then you will need to use nested looping (see the Zapier For Each Loop Quick-Start Guide).

Set up of the Zapier loop through array action
Zapier loop through array action setup

After the “Values to Loop” have been setup, they can then be used in subsequent steps to supply a different value for that variable for each iteration of the loop.

Send Email for Each Array Value

Image showing the body of the outbound email populated with array information
Email body populated with array information

Send SMS for Each Array Value

Image showing the body of the outbound sms populated with array information
SMS populated with array information

If you have not yet gotten yourself set up with Telnyx then take a look at the Marketo 2 Way SMS using Telnyx and Zapier post to see how to get started with sending SMS.

One thing to note about sending SMS is that there are rate limits that apply to certain number types so if you try and exceed these limits, which is very likely when you loop through arrays, then the carrier will throttle the messages and spread them out over a longer timespan to ensure delivery. Therefore, do not expect all your SMS to be delivered right away when looping.

This throttling is implemented to prevent fraudsters and bad actors from easily being able to spam people with large amounts of SMS at once. If higher rate limits are needed you can get verified by your carrier who can then increase your rate limit or allow you to purchase another number type with higher throughput e.g. a short code number. If you want to learn more about rate limits and the pros and cons of the different number types then take a look at the Marketo SMS Marketing with Telnyx post.

Post Loop Subsequent Actions

As shown in the flow diagram in the introduction, you can use a filter to stop looping so that actions after the filter will only run once. This is achieved by checking if the “Loop Iteration is Last” value from the loop through array action in Step 2 is TRUE.

Filter  setup to only allow progression once the Zapier loop through array action has finished
Filter setup to only allow progression once the Zapier loop through array action has finished

Now that the Zap has progressed beyond the filter, a single summary email and SMS can be sent to a customer manager so that they can see all the customers who will receive deliveries today. Notice how the bodies of the email and SMS are using the array values from the webhook in Step 1 instead of the looping variables from Step 2. This is important because we want all the array values to be present in a single message, as shown in the SMS inbox image below.

Summary email populated with array information from Google Sheets
Summary email populated with array information from Google Sheets
Gmail inbox showing the summary email and emails for each array value
Gmail inbox showing the summary email and emails for each array value
Summary SMS populated with array information from Google Sheets
Summary SMS populated with array information from Google Sheets
SMS inbox showing the summary message and messages for each array value
SMS inbox showing the summary message and messages for each array value

What’s Next?

There you have it! That is how you can use Zapier to loop through arrays imported from Google Sheets so that you can carry out actions in bulk for each array value.

This example used the “Create Loop from Text” action from the “Looping by Zapier” app. There are 2 more actions available that you can use for looping: “Create Loop from Line Items” and “Create Loop from Numbers”. These actions are covered, respectively, in the posts below:

If you are interested in nested looping within Zapier then take a look at the Zapier For Each Loop Quick-Start Guide.

About The Author — Tyron Pretorius
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.

Related free workshops

Google Sheets data being accessed in a Zap action in Zapier

How to use Zapier with Google Sheets

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.

Become a member
Timestamp being used as the Google Sheets lookup value in Zapier

Zapier Google Sheets Lookup Value

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.

Become a member
Button in Google Sheets to trigger a Google Script to send multiple rows to Zapier

Zapier Import Multiple Rows from Google Sheets

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.

Become a member