Back to Blog

Easy to Follow Guide to Klaviyo Google Sheets Integration

Klaviyo is a go-to marketing automation platform for 100,000+ global companies. It helps e-commerce businesses deliver personalized experiences through its data-driven tools. The platform has quite impressive analytics features and metrics that help businesses determine their next marketing move.

You can connect Klaviyo to Google Sheets and export the data to get a complete view of the marketing performance. Let’s explore the ways to integrate Klaviyo into Google Sheets.

Different ways to integrate Klaviyo into Google Sheets

Klaviyo allows exporting data into .csv files, which can be later imported into Google Sheets. This method requires repeating the manual export-import process every time you need fresh data. Therefore, it is not a feasible method if you’re looking to connect Klaviyo to Google Sheets and integrate the data flow. 

The best part of Klaviyo is its seamless integration ability with other platforms. The availability of API makes it possible to connect it with any other platform or tool. API (Application Programming Interface) is a mechanism that enables the communication between two applications through a common protocol.

Here are the ways to connect Klaviyo API with Google Sheets:

  • ETL tool by Coupler.io: No-code and easy-to-follow method to connect Klaviyo to Google Sheets. Requires less technical expertise.
  • Google Apps Script: Programmatic method to pull data from Klaviyo to Google Sheets using Google Apps Script. Demands knowledge of Apps Script.

Both methods use Klaviyo API to integrate Google Sheets. Take reference from the Klaviyo API documentation to learn more about the data you can import.

How to generate Klaviyo API key?

Klaviyo API Key is required to get the Klaviyo data through API. It acts just like a password to authenticate the request.

To get your Klaviyo API Key, log into your account dashboard and follow these steps:

  • On the bottom-left corner of the page, click on your profile and go to Settings.
1 go to klaviyo account settings
  • In the Account Settings, navigate to the API Keys tab, where all your public and private API keys will be listed. We need the private API key to connect Klaviyo to Google Sheets. Click the Create Private API Key button.
2 create klaviyo api key
  • Next, enter the Private API Key Name and select the Access Level, which will be the Full Access Key in our case. Choose Read-Only Key if you want to just import Klaviyo data into Google Sheets. Finally, click Create to get the Klaviyo API Key.
3 define api key access in klaviyo
  • Your Klaviyo API Private Key will be displayed on the screen. Copy the Key and download it for future use.
4 copy download klaviyo api key
  • You can also find the generated API key under the Private API Keys section in Settings > API Keys.
5 generated api keys in klaviyo

Now, we are ready to go for the Klaviyo Google Sheets integration. You can follow any of the two methods below for successful integration.

Automate Klaviyo Google Sheets integration without coding

Do you want to connect Klaviyo to Google Sheets and import data on schedule? Well, Coupler.io has got you covered!

Coupler.io is a data automation and analytics platform that offers an ETL tool to extract data from various sources into destinations such as Excel and Google Sheets. With the help of the JSON connector, you can integrate Klaviyo with Google Sheets and automate the data flow.

Note: In this method, you need to modify the JSON URL and parameters as per Klaviyo API to get the required data. We are not responsible for any errors arising because of misconfigurations or changes in the app’s API. You can request this premium integration at Coupler.io.

First, create a Coupler.io account and log into the dashboard. Create an importer and select JSON as the source and Google Sheets as the destination app.

6 create an importer in coupler

Next, click Proceed and configure the following settings for Klaviyo Google Sheets integration.

Source

  • In the JSON URL, enter the respective Klaviyo API endpoint to get the required data. For example, to get the list of profiles, use the following API endpoint:
https://a.klaviyo.com/api/profiles

Read the Klaviyo API documentation to learn endpoints for different data you can export. 

  • Select GET in the HTTP method.
  • In the Request headers, specify the Klaviyo API key that we generated earlier, and add the revision date of the API endpoint.
    • Authorization – Klaviyo-API-Key {your_private_api_key_here}
    • Revision – 2023-02-22

(Klaviyo keeps updating its API regularly. You need to specify the release date of the API version you’re using in the header. Currently, the latest and stable version is v2023:02:22)

7 configure source in coupler

Optionally, you can also specify the URL query parameters, required Columns, and Path in the Source configuration as per the data requirements.

  • Click Jump to Destination Settings to proceed further.

Destination

  • In the Account, log into your Google account and authorize access to Coupler.io.
  • Select the Spreadsheet in your account where you want to import the Klaviyo data.
  • Next, select the destination Sheet and click Jump to Schedule Settings.
8 configure destination in coupler

Optional destination settings

Coupler.io lets you specify the target Cell address/Range for the Klaviyo data import. The default is the A1 cell. You can also choose the import mode from the following:

  • Replace: The old data in the sheet will be replaced by a new one on each refresh.
  • Append: The new data will be added to the sheet on every refresh. Old data will remain intact.

Next, click Continue to proceed with the next section.

Schedule

  • Enable the Automatic data refresh to update the Klaviyo data in Google Sheets on schedule.
  • Select the Interval of the auto-refresh and choose the applicable Days of the week.
  • Specify the preferred time for the data update and click Save and Run.
2 schedule

Once the data is imported without any error, a success message will be displayed on your screen. Here’s the Klaviyo data in Google Sheets exported using Coupler.io.

10 klaviyo google sheets integration using coupler

Well, that’s so easy! Furthermore, this data will be refreshed at regular intervals as per the configuration in the Coupler.io importer.

You can also install the Coupler.io add-on in Google Sheets for ease of management. Once installed, you can find it under the Extensions tab.

11 open coupler add on in google sheets

In the add-on, the Coupler.io dashboard lets you manage the importers directly from Google Sheets.

12 coupler google sheets addon

Well, that’s Klaviyo Google Sheets integration made easy by Coupler.io. Create as many importers as you need by calling different API endpoints to import the desired data!

Connect Klaviyo to Google Sheets using Google Apps Script

Google Apps Script is a JavaScript-based language supported by Google Workspace to integrate various applications. You can use the Google Apps Script to call the Klaviyo API, fetch the required data, and import it into Google Sheets.

This method demands high proficiency in the JavaScript language and working with APIs. Let’s say you want to get all the profiles from Klaviyo into Google Sheets. You can follow these steps to do that using Google Apps Script:

  • Open the Google Sheet where you want to import Klaviyo data and go to Extensions > App Script.
13 open extensions app script in google sheet
  • In the script editor, copy and paste the following code:
function ListProfiles() {
   const API_URL = "https://a.klaviyo.com/api";
   const DATA_ENDPOINT = "/v1/people";
   const API_KEY = "Your_Klaviyo_API Key";
   const response = UrlFetchApp.fetch(API_URL + DATA_ENDPOINT + "?api_key=" + API_KEY);
   const content = JSON.parse(response.getContentText());
   const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // Change Sheet1 to the name of your sheet




  // Create the header row 
  var headerValues = ["ID", "Email", "First Name", "Last Name", "Address 1", "Address 2", "City", "Country", "Region", "Zip", "Title", "Phone Number", "Organization", "Updated"]; // the header row values
  sheet.getRange(1, 1, 1, headerValues.length).setValues([headerValues]); // add the new header row


   // Get existing data in sheet
   const dataRange = sheet.getDataRange();


   const values = dataRange.getValues();




   // Loop through Klaviyo data and update sheet
   for (let i = 0; i < content.data.length; i++) {
       const id = content.data[i].id;
       
       // Check if id already exists in sheet
       let existingRowIndex = -1;
       for (let j = 1; j < values.length; j++) { // Start at 1 to skip header row
           if (values[j][0] == id) { // Column 1 contains the id
               existingRowIndex = j + 1; // Add 1 to account for header row
               break;
           }
       }
       
       // If id exists, update other details in same row
       if (existingRowIndex > 0) {
           const rowToUpdate = sheet.getRange(existingRowIndex, 1, 1, 14);
           rowToUpdate.setValues([[id, content.data[i].email, content.data[i].first_name, content.data[i].last_name, content.data[i]['$address1'], content.data[i]['$address2'], content.data[i]['$city'], content.data[i]['$country'], content.data[i]['$region'], content.data[i]['$zip'], content.data[i]['$title'], content.data[i]['$phone_number'], content.data[i]['$organization'], content.data[i].updated]]);
       }
       
       // If id doesn't exist, add new row
       else {
           sheet.appendRow([id, content.data[i].email, content.data[i].first_name, content.data[i].last_name, content.data[i]['$address1'], content.data[i]['$address2'], content.data[i]['$city'], content.data[i]['$country'], content.data[i]['$region'], content.data[i]['$zip'], content.data[i]['$title'], content.data[i]['$phone_number'], content.data[i]['$organization'], content.data[i].updated]);
       }
   }
}

Remember to replace Your_Klaviyo_API Key in the above code with your Klaviyo Private API Key that we generated earlier.

  • Next, save the script and click Run to execute the code.
14 run script to import klaviyo data into google sheets
  • You may be prompted to authorize the permission to run the script. Click on Review permissions.
15 review app permission in google apps script
  • On the Google authorization popup, select the respective Google account.
  • Now, a warning message will appear on your screen. Click on Advanced and click on Go to {app name} to proceed further.
16 safety warning
  • Finally, click on Allow to grant app script access to your Google account data, which is required to import Klaviyo data to Google Sheets.
17 allow access to google app script
  • On successful execution of the script, the required Klaviyo data will be successfully imported to the Google Sheet.
18 connect klaviyo to google sheets using app script

Please note that the above-provided code is just an example of fetching profile data from Klaviyo to Google Sheets. It is programmed to replace the existing data with a fresh one on each run. You may need to modify the code, use different API endpoints, and other functions to retrieve data and make it function as per your requirements.

Once everything looks good, you can configure the Google Apps Script to automate data importing. Let’s see how to do that.

Auto-update Google Sheets from Klaviyo at regular intervals

Google Apps Script supports various event-based triggers to auto-run functions. You can create a time-based trigger to automatically import Klaviyo data to Google Sheets at regular intervals.

Let’s say you want to update Google Sheets every minute for the latest data. You can follow these steps:

  • In the Google Apps Script, click on Triggers in the left-most panel.
19 click on triggers
  • In the Triggers section, click Create a New Trigger.
20 create a new trigger in google apps script
  • Now, choose the function in the apps script which you want to call regularly.
  • Select the event source as Time-driven, the timer as Minutes timer, and the interval as Every Minute.
  • Finally, click Save to create the Trigger.
21 set up trigger in google apps script

Optionally, you can also choose the frequency to receive notifications in case of apps script failure.

Now, Google Apps Script will run the script at regular intervals to auto-update data in Google Sheets from Klaviyo.

Which is the best method for Klaviyo Google Sheets integration?

Connecting Klaviyo to Google Sheets can help you import data such as profiles, campaigns, and metrics to analyze your marketing performance. In this article, we learned two main ways to integrate Klaviyo into Google Sheets.

Klaviyo Google Sheets integration using the Google Apps Script method requires coding expertise. This can be challenging and is prone to technical errors. Therefore, the best method to connect Google Sheets to Klaviyo is using ETL tool by Coupler.io. The platform automates the integration with minimum technical knowledge. It also supports integration with 60+ data sources to help you make the most out of your data.

  • Zakhar Yung

    A content manager at Coupler.io whose key responsibility is to ensure that the readers love our content on the blog. With 5 years of experience as a wordsmith in SaaS, I know how to make texts resonate with readers' queries✍🏼

Back to Blog

Comments are closed.

Focus on your business
goals while we take care of your data!

Try Coupler.io