What This KB Article Is About
A step-by-step guide for connecting SellerLegend with Google Sheets to automatically pull your Sales Statistics data.
Please note: This feature is a Proof-of-Concept only. It is not part of the SellerLegend product development roadmap and is not officially supported by our development or support teams. As such, no Service Level Agreement applies, and we cannot guarantee fixes for bugs or malfunctions.
We welcome feedback and ideas for improvement; however, any updates or enhancements will be considered solely at our discretion and implemented only if time and resources allow.
What You’ll Need
Before starting, make sure you have:
-
A Google account (for Google Sheets)
-
A SellerLegend account with API access enabled
-
About 15–20 minutes to complete the setup
Step 1: Create Your Google Sheet
-
Open Google Sheets
-
Go to sheets.google.com
-
Click the “+” button to create a new blank spreadsheet
-
-
Name Your Spreadsheet
-
Click on “Untitled spreadsheet” at the top
-
Name it as “SellerLegend Data Integration”
-
The sheet will auto-save
-
Step 2: Add the Integration Script
-
Open Apps Script Editor
-
In your Google Sheet, click Extensions in the menu
-
Select Apps Script
-
A new tab will open with a code editor
-
-
Clear Default Code
-
You’ll see some default code like
function myFunction() {}
-
Select all the text (Ctrl+A on Windows, Cmd+A on Mac)
-
Delete it
-
-
Add the Integration Script
-
Copy the entire contents of
google-sheets-oauth-integration.js
-
Paste it into the Apps Script editor
-
Click the 💾 Save icon (or press Ctrl+S / Cmd+S)
-
Name the project “SellerLegend Integration” when prompted
-
Step 3: Deploy as Web App
This step creates a URL that SellerLegend will use to send authorization codes back to your sheet.
-
Start Deployment
-
In the Apps Script editor, click the Deploy button (top right)
-
Select New deployment
-
-
Configure Deployment
-
Click the gear icon ⚙️ next to Select type
-
Choose Web app
-
Fill in these settings:
-
Description: OAuth Callback Handler
-
Execute as: Me (your email will show here)
-
Who has access: Anyone
-
-
-
Deploy and Copy URL
-
Click Deploy
-
Authorise the app when prompted (select account → Advanced → Continue)
- A modal appears “The web app requires you to authorise access to your data.” with an “Authorise Access” button.
- Click on the button
- A modal appears to select your Google account. Select your account of choice.
- A modal appears “Google hasn’t verified this app”
- Click on “Advanced”
- Click on “Go to SellerLegend Integration (unsafe)”
- A modal appears “SellerLegend Integration wants to access your Google Account”
- Click on “Allow”
-
⚠️ IMPORTANT: A window will appear with your Web App URL
-
Copy this entire URL — it looks like:
-
Save this URL in a notepad — you’ll need it in Step 4
-
Click Done
-
-
Return to Your Google Sheet
-
Close the Apps Script tab
-
Refresh the Google Sheet (F5 or Cmd+R)
-
You should now see a new menu item: SellerLegend OAuth
-
Step 4: Create SellerLegend OAuth Client
Now we’ll create credentials in SellerLegend that allow Google Sheets to access your data.
-
Login to SellerLegend
- Go to your SellerLegend Account Settings
-
Navigate to Account → Developers
-
Or go directly to:
https://app.sellerlegend.com/account/developers
-
Create New OAuth Client
-
Click Create New Client
-
Fill in the form:
-
Name: Google Sheets Integration
-
Redirect URL: Paste the Web App URL from Step 3 (the `https://script.google.com/macros/s/…/exec` URL)
-
Leave the box Confidential ticked
-
-
Click Create
-
-
Copy Your Credentials
-
After creation, note down:
-
Client ID (usually a number like “2” or “3”)
-
Client Secret a long string of random characters
-
-
Copy both of these. Keep this window open for later reference or save in notepad
-
⚠️ IMPORTANT SECURITY NOTICE
Your Client ID, Client Secret, Authorization Code, Access Token, Refresh Token, and similar credentials are highly confidential. Never share them with anyone.These credentials are stored unencrypted within your Google Sheet and grant the same level of access as your SellerLegend password. If exposed, your account and data could be compromised.
Treat this information with the highest level of security — restrict access to the sheet, store backups securely, and remove credentials when they are no longer needed.
Step 5: Connect to SellerLegend
Now we’ll connect your Google Sheet to SellerLegend using the credentials.
5.1. Setup OAuth in Google Sheets
1. Initialize OAuth Settings
-
- In your Google Sheet menu, click SellerLegend OAuth menu item
- Click 1. Setup OAuth
- Click OK when the setup complete message appears
- A new sheet tab called “OAuth Settings” will be created
2. Enter Your Credentials
-
- Go to the OAuth Settings sheet tab
- Find these cells and fill them in:
- Cell B2 (Client ID): Enter your Client ID from SellerLegend (e.g., “2”)
- Cell B3 (Client Secret): Enter your Client Secret from SellerLegend
- Cell B4 (Base URL): Should already say `https://app.sellerlegend.com`
- Leave other fields as they are
5.2 Add Redirect URI
-
In the OAuth Settings sheet
- Find Cell B5 (Redirect URI)
- Paste the same Web App URL you copied in Step 3.3
- This should be the `https://script.google.com/macros/s/…/exec` URL
5.3 Get Authorization
- Start Authorization
- Click SellerLegend OAuth menu
- Click 2, Get Authorization Code
- A dialog will appear with a link “Open Authorization Page”
- Authorize Access
- Click the **”🔗 Open Authorization Page”** link
- This opens SellerLegend in a new tab
- Login if prompted
- Click Authorize to grant access
- You’ll see an authorization code on the screen
- Copy the Authorization Code
-
- Copy the entire authorization code shown
- Go back to your Google Sheet
- Dismiss the Oauth Authorization box (click on X)
- Go to the OAuth Settings sheet tab
- Paste the code in cell B8 (Authorization Code row)
5.4 Get Your Access Token
-
Click SellerLegend OAuth → Exchange Code for Token
-
Token details will be stored automatically
5.5 Test the Connection
-
Click SellerLegend OAuth menu
-
Click Test API Connection
-
If you see your user info (ID, Name, email, etc.) — ✅ success
Step 6: Fetch Your Accounts
Before fetching sales data, you need to get your SellerLegend accounts (marketplaces)
-
Click SellerLegend OAuth
-
Click on Get Accounts
- Wait a moment while it fetches your accounts
- You’ll see a success message showing how many accounts were found
- Check your accounts
- A new tab Accounts will appear with all your SellerLegend accounts, including:
-
Account title
-
Marketplace (US, UK, etc.)
-
Currencies
-
Seller IDs
-
- A new tab Accounts will appear with all your SellerLegend accounts, including:
- Click on OK to dismiss the account retrieval box
Step 7: Setup Sales Statistics Dashboard
Now let’s configure the dashboard to fetch sales data.
-
Create Configuration
-
Click SellerLegend OAuth
-
Click on Setup Sales Stats Dashboard
- Click OK when setup is complete
-
A new sheet Sales Stats Config sheet will appear
-
- Understanding the configuration
The Sales Stats Config sheet has these settings:
Parameter | What It Means | Example |
---|---|---|
Account | Which SL account to use | Your store name |
View By | Group data by product/date | product / date |
Group By | How to group the data | SKU, ASIN, Product |
Start Date | Start date | 2024-01-01 |
End Date | End date | 2024-01-31 |
Currency | Currency for amounts | USD, GBP, EUR |
Per Page | how many Results per fetch | 500, 1000, 2000 |
Filter By | Optional filter type | sku / asin or leave empty |
Filter Value | Value to filter for | SKU12345 |
Sales Channel | amazon / non-amazon / blank | amazon |
Target Sheet | Where to put the data | Product Sales |
Page | Which page of results | 1, 2, 3 |
Write Mode | How to handle existing data | Overwrite or Append |
Using the Sales Stats Dashboard
Basic Usage: Fetch All Products for Last 30 Days
- Configure Settings
- In Sales Stats Config sheet:
- Account: Select your account from dropdown
- View By: Keep as “product”
- Group By: Keep as “Product”
- Start Date: Already set to 30 days ago
- End Date: Already set to today
- Target Sheet: Type “Product Sales” (or any sheet name)
- Write Mode: Select “Overwrite”
- In Sales Stats Config sheet:
- Fetch the Data
- Click SellerLegend OAuth menu
- Click Fetch Sales Statistics
- Wait while data is fetched (may take 10-30 seconds)
- Success message will show how many rows were fetched
- View Your Data
Click on the sheet tab with your target sheet name
You’ll see all your products with:- SKUs and ASINs
- Units sold
- Revenue and costs
- Profit margins
Advanced Usage Examples
Example 1: Get Daily Sales for Specific Product
- Configure:
- View By: “date”
- Group By: “Date” (will change automatically)
- Filter By: “SKU”
- Filter Value: Your product SKU
- Target Sheet: “Daily Sales”
- Fetch:
- Click “Fetch Sales Statistics”
Example 2: Combine Multiple Pages of Data
1. For Page 1:
-
- Set Page: “1”
- Set Write Mode: “Overwrite”
- Fetch the data
2. For Page 2:
-
- Set Page: “2”
- Set Write Mode: “Append”
- Fetch the data
- Page 2 will be added below Page 1
Example 3: Compare Different Time Periods
1. January Data:
-
- Set dates to January
- Target Sheet: “Monthly Comparison”
- Write Mode: “Overwrite”
- Fetch
2. February Data:
-
- Change dates to February
- Same target sheet
- Write Mode: “Append”
- Fetch
- Both months now in same sheet for comparison
Understanding Write Modes
- Overwrite: Clears the target sheet and adds fresh data
- Use for: Single queries, starting fresh
- Append: Adds new data below existing data
- Use for: Multiple pages, combining date ranges, building reports
Tips for Success
- Start Small
- Test with short date ranges first (7 days)
- Once working, expand to longer periods
- Use Filters Wisely
- Filter by SKU to track specific products
- Filter by ASIN to group variations
- Save Different Configs
- Create multiple sheets with different saved configurations
- Copy the Sales Stats Config sheet to save different setups
- Check Your Data
- The TOTAL row at bottom shows sums
- Use Google Sheets charts to visualize trends
Troubleshooting
Common Issues and Solutions
-
“No access token found”
-
Solution:
-
Run through Step 5 again to get a new token
-
-
-
“Token expired”
- Solution:
- Click SellerLegend OAuth → Refresh Access Token
- Or get a new token using Get New Access Token (Client Credentials)
- Solution:
-
“No data found”
-
Check:
-
Date range has sales data
-
Account selection is correct
-
Filters aren’t too restrictive→ Check date range, filters
-
-
- “Failed to fetch accounts”
- Check:
- Token is valid (test connection first)
- You have accounts in SellerLegend
- Check:
- Data looks wrong
- Check:
- Currency setting matches your needs
- Date range is correct
- View By and Group By match your intent
- Check:
Getting Help:
- Check Logs
- In Google Sheets: Extensions → Apps Script
- Click Executions (left sidebar)
- Click on recent execution to see detailed logs
- Token Issues
- Tokens expire after 15 days
- Set a reminder to refresh monthly
- Or use Client Credentials token (doesn’t expire)
- Need More Help?
- Check your SellerLegend API documentation
- Contact SellerLegend support for API issues (No guaranteed SLA as this is a proof of concept/example)
- For script issues, check the error messages in logs
Best Practices
- Security
- Never share your Client Secret
- Don’t share the OAuth Settings sheet with others
- Keep your Google Sheet private or view-only for others
- Performance
- Fetch smaller date ranges for faster results
- Use filters to reduce data volume
- 500 per page is usually fastest
- Organization
- Create separate sheets for different reports
- Use clear target sheet names
- Document your configurations
- Maintenance
-
- Refresh token before it expires (every 2 weeks)
- Check for script updates periodically
- Keep your configurations backed up
Congratulations! 🎉
You’ve successfully connected SellerLegend to Google Sheets! You can now:
-
Pull sales data automatically into Google Sheets
-
Create custom reports
-
Track performance over time
- Export data for further analysis
Quick Reference Card
Daily Tasks:
-
Open sheet
-
Adjust date range
-
Fetch data
-
Review
Weekly Tasks:
-
Refresh token (if needed)
-
Check errors
-
Update configs as needed
Google Sheets Menu Options Quick Guide:
-
Setup OAuth – First time setup only
-
Get Authorization Code – Start auth process
-
Exchange Code for Token – Complete auth
-
Test API Connection – Verify it works
-
Get Accounts – Fetch your accounts
-
Setup Sales Stats Dashboard – Create config sheet
-
Fetch Sales Statistics – Get your data!
-
Refresh Access Token – Renew expired token
Last updated: 13 August 2025
Script version: 0.1