Sometimes, as market researchers, we find ourselves juggling an endless stream of customer feedback, brainstorming notes, and survey data, all funnelled into sprawling spreadsheets.
Well, we often do.
Wouldn’t it be brilliant if ChatGPT could jump right in to summarise, categorise, or even spark new ideas within Google Sheets itself? Good news: it can.
Why the API Instead of the Web-Based Tool?
Before we get into the nitty-gritty, let’s talk about why you might prefer the API over using ChatGPT directly in your browser. If you’re a busy market researcher (or just a spreadsheet fan), there are a few big reasons:
- Bulk Operations: Handling a large volume of text? The web-based interface is great for quick, one-off queries, but if you’re juggling dozens or hundreds of rows every day, you’ll crave a more automated approach.
- Customisation and Control: With the ChatGPT API, you can tweak parameters (like temperature or model version) and integrate results back into your Sheets. Everything stays in one place, so you stay in the driver’s seat.
- Automated & Custom Integrations: With the API, you can programmatically pull data from multiple sources (not just one uploaded file), process it in real time (or on a schedule), and then feed the results back into Google Sheets or any other system you choose. This also allows you to build custom logic (for example, automatically emailing a summary every morning, sending alerts to a Slack channel, or triggering next-step tasks in project management software). Essentially, the API lets you stitch ChatGPT’s capabilities into a seamless, multi-tool workflow, something that even a robust web interface can’t fully replicate.
If any of those points make you feel a tiny spark of excitement, let’s dive in.
1. Sorting Out Payment: Why Add Funds First?
OpenAI no longer provides default free credits, so we recommend depositing $5 in your OpenAI Billing Dashboard before you start. When you top-up your account, you are basically buying tokens.
A token is a small chunk of text (often a short word or part of a word). Both your prompt (what you send) and ChatGPT’s reply (what you receive) consume tokens.
- Short Text: A short query (200 tokens) plus a short answer (100 tokens) → ~300 tokens total, costing a tiny fraction of a cent.
- Long Text: A large prompt (3,000 tokens) plus a long summary (2,000 tokens) → 5,000 tokens at once, which uses more of your budget.
- Where Your $5 Goes: Prompt tokens cost $0.0015 per 1,000; completions cost $0.002 per 1,000. On average, $5 can fund a couple million tokens (enough for thousands of short interactions if you’re mindful). Long, detailed prompts and replies, however, eat through tokens faster.
By adding a small deposit and keeping tokens in mind, you’ll avoid unexpected “quota exceeded” messages and fully leverage ChatGPT’s capabilities right in Google Sheets.
2. Generate (or Retrieve) Your OpenAI API Key
Now that you’ve sorted your billing, let’s secure the magic password that will connect ChatGPT to your Sheet (your API key).
- Create or Log In to OpenAI: Head to the OpenAI Platform and sign in or register.
- Organise Your Keys: Under Get your API keys, click Start Building, then create or select an organisation name if prompted.
- Create a New Secret Key: Go to View API keys or Create new secret key, and generate your key. Anyone with this key can charge your account, so keep it private.
3. Open Google Sheets & Apps Script
Time to switch gears from OpenAI’s dashboard to your trusty Google Sheet.
- Pick a Sheet: It can be a brand-new file or an existing sheet full of user comments, product ideas (whatever you want ChatGPT to dig its digital teeth into).
- Navigate to Apps Script: In your Sheet, click Extensions > Apps Script. A new tab appears, often showing a placeholder function.
- Delete Default Code: Remove any existing code. Starting with a fresh page makes setup simpler.
4. Create Your ChatGPT Script
Now, let’s set up the code that will communicate with ChatGPT behind the scenes. This code allows your spreadsheet to send prompts to the AI and get answers back right in the cells of your sheet.
- Add a New File: In the Apps Script editor (the window that opened when you went to Extensions > Apps Script), look at the left-hand panel. If you see a file called “Code.gs”, you can either edit it directly or create a new one by clicking the plus icon. If you create a new file, name it something like ChatGPT.gs to keep things organised.
- Paste the Code: Copy the following code (below) and paste it into the .gs file you’re working in. Make sure the file is empty of any code before pasting it in.
🔔 Important: Replace “YOUR_OPENAI_API_KEY” with the actual API key you obtained from the OpenAI dashboard.
/**
* Main function (for testing in the script editor).
*/
function myFunction() {
// Example prompt
var testPrompt = "Hello, ChatGPT! Summarise how to integrate with Google Sheets.";
// Call ChatGPT and log the response
var result = getChatGPTResponse(testPrompt);
Logger.log(result);
}
/**
* The function you'll call from your Google Sheet.
* Example: =getChatGPTResponse("Your prompt here")
*/
function getChatGPTResponse(prompt) {
var apiKey = "YOUR_OPENAI_API_KEY"; // Replace with your actual key
var url = "https://api.openai.com/v1/chat/completions";
var payload = {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": prompt
}
]
};
var options = {
"method": "post",
"headers": {
"Authorization": "Bearer " + apiKey,
"Content-Type": "application/json"
},
"payload": JSON.stringify(payload)
};
var response = UrlFetchApp.fetch(url, options);
var json = JSON.parse(response.getContentText());
// Return the text from the first response
return json.choices[0].message.content.trim();
}
- Save the Project: Hit the save icon or press Ctrl+S. Name it something memorable (for example, “ChatGPT Integration”).
You’ll know the setup works when either the test function in the script editor returns a valid response from ChatGPT in the Execution log window. You will know this has worked as you will see a response to the question Summarise how to integrate with Google Sheets which was in the setup code.
🔔 Important: Before seeing this response, Google will prompt you to authorize the script. Follow the on-screen instructions, choose “Advanced” if necessary and allow the permissions requested to grant the script access to your account and external services. Once authorized and executed, the presence of a valid response in the logs indicates that everything is set up correctly.
5. Test the Script
Now for the fun part: seeing if it all works.
Let’s try a formula in Google Sheets. HeadBack in your spreadsheet, paste the following into a cell:
=getChatGPTResponse("Hello from the spreadsheet! Could you greet me like a punk rocker?")
Press Enter, approve any final permissions, and ChatGPT’s reply should appear in your chosen cell.
🔔 Important: Watch for 429 errors – If you see a “quota exceeded” message, you might be hitting rate limits or you never added funds. Head back to your OpenAI Usage page to confirm.
6. Putting ChatGPT to Work in Market Research
Now Let’s try out some basic prompts on a synthetic dataset. You can download it HERE and simply copy and paste it into your Google Sheet (or upload it).
Now that you have a dataset covering both numeric ratings (taste, price importance, and repurchase likelihood) and open-ended feedback (flavour description, improvement ideas, and a one-sentence product summary), it’s time to put ChatGPT to work.
Below you’ll find example formulas designed to handle each question type, ranging from sentiment analysis to category-based improvements, so you can quickly turn raw responses into actionable insights. Simply paste these formulas into new columns in your sheet, copy them down through all rows, and watch as your market research data transforms into organised, AI-assisted feedback.
The dataset contains the following questions.
- Q1 (Column B): On a scale of 1–5, how would you rate the taste? (Quantitative)
- Q2 (Column C): On a scale of 1–5, how important is price to you? (Quantitative)
- Q3 (Column D): On a scale of 1–5, how likely are you to repurchase? (Quantitative)
- Q4 (Column E): In a few words, describe the flavour experience. (Qualitative)
- Q5 (Column F): What could be improved about this product? (Qualitative)
- Q6 (Column G): Summarise the product in one sentence. (Qualitative)
📝 Qualitative Prompt Examples
💙 Sentiment Analysis of Flavour Experience
In a new cell, say H2, copy the following code:
=getChatGPTResponse("Assess the sentiment of this flavour description (very negative, negative, neutral, positive, or very positive) and briefly explain why in one sentence. Description: " & E2)
What It Does: Looks at the short flavour description (Q4), provides a sentiment rating (e.g. “negative” or “positive”), and offers a single-sentence rationale.
Copy Down: Drag or double-click the fill handle from H2 through H51, so each row’s sentiment is automatically analysed.
🚨 Category & Action for Improvement Suggestion
In a new cell, say I2, copy the following code:
=getChatGPTResponse("Here’s the improvement suggestion: " & F2 & ". Assign it to one of these 5 categories (Taste, Price, Branding, Packaging, Other), then give one practical step to address it.")
What It Does: Takes Q5 (the open-ended improvement suggestion), places it in one of five possible categories, and provides an action step.
Copy Down: Again, drag or double-click the fill handle to fill rows 2–51, categorising each suggestion and giving a tailored action.
📱 Building on the Product Summary
In a new cell, say J2, copy the following code:
=getChatGPTResponse("The user summarises the product as: " & G2 & ". Suggest one marketing angle based on this summary.")
What It Does: Reads Q6 (the user’s one-sentence summary) and turns it into a marketing angle.
Copy Down: Fill down for rows 2–51.
🧮 Quantitative Prompt Examples
😋 Taste Rating Analysis
In a new cell, say K2, copy the following code:
=getChatGPTResponse("They rated the taste " & B2 & "/5. Their flavour description is: " & E2 & ". Suggest one reason for this rating.")
What It Does: Merges the numeric taste rating (Q1) with the user’s flavour comments (Q4) to hypothesise why they gave that specific rating.
Copy Down: Drag to fill each row, so each numeric rating plus the user’s flavour experience is addressed.
💰 Price Importance vs. Improvement Idea
In a new cell, say L2, copy the following code:
=getChatGPTResponse("They rated price importance " & C2 & "/5. Their improvement idea is: " & F2 & ". How might cost adjustments address this suggestion?")
What It Does: Considers how important price is (Q2) alongside the user’s recommended improvement (Q5), then ties those together in a cost-focused action plan.
Copy Down: Fill for rows 2–51.
🛒 Repurchase Likelihood & Action Steps
In a new cell, say L2, copy the following code:
=getChatGPTResponse("Given a repurchase likelihood of " & D2 & "/5, suggest one brand action that might increase this rating.")
What It Does: Uses the numeric repurchase likelihood (Q3) to propose a strategy that could boost that rating.
Copy Down: Fill for rows 2–51.
7. Disconnecting or Removing Access
If you decide you no longer need ChatGPT in your Google Sheet (or simply want to remove access), there are three main steps you can take:
Delete the Script: Go to Extensions > Apps Script and remove either the file containing your code or the entire project. Once deleted, ChatGPT won’t be callable from your spreadsheet.
Revoke Permissions in Your Google Account: Visit My Account Security and look for “Apps with account access.” Locate your script and remove its permissions. This ensures it can’t fetch data or run in the background.
Disable Your OpenAI Key: Log in to the OpenAI Platform and revoke the API key you created. This immediately prevents any further calls or charges associated with that key.
Taking one or more of these steps fully disconnects your Sheet from ChatGPT, so you can rest assured there’s no lingering access or usage.
📢 Final Words
By weaving ChatGPT into your spreadsheet, you can save hours of data wrangling (whether you’re summarising free-form text or brainstorming new taglines). Keep an eye on your token usage (short queries and concise answers save you money) and don’t forget you can follow up on ChatGPT’s responses to dive deeper into your analysis.
Now that you have everything set (billing, the API key, and working code) the doors to more efficient market research are wide open.
Enjoy your new AI-powered workflow! 🤘
This training guide is yours to use however you like. Share it, apply it in your business, or adapt it to fit your brand. That is what DIY culture is all about! If you find it valuable, consider supporting my work with a coffee or a beer through my Buy Me a Coffee link below. Cheers! ☕🍻

