Streamline your data collection by connecting the LinksToro extension directly to Google Sheets. This integration automatically saves domain analysis data to a spreadsheet, creating a centralized database for your projects. Follow this simple guide to set it up.
Setting Up the Google Sheets Connector
The setup process involves creating a simple script in your Google account that will act as a bridge between the extension and your spreadsheet.
Create and Deploy the Google Apps Script
- Create a new spreadsheet.
- Navigate to Google Apps Script and start a New Project.

- Give the project a recognizable name, such as “LinksToro Connector.”
- Delete the default code in the editor and paste in the provided script code for the integration. Replace ___ in the code with your SPREADSHEET_ID, which can be found in the spreadsheet URL.

Click to see the code
/**
* Handles POST requests from the LinksToro extension to add data to a Google Sheet.
*/
function doPost(e) {
try {
let data;
let values;
// The spreadsheet ID where data will be stored.
// IMPORTANT: You can replace this with your own spreadsheet ID if you use the “Advanced Configuration” steps.
const SPREADSHEET_ID = ‘___’; // Placeholder ID from original script
// Attempt to parse incoming data (handles both JSON and form data)
if (e.postData && e.postData.contents) {
if (e.postData.type === ‘application/json’) {
data = JSON.parse(e.postData.contents);
values = data.values;
} else {
const formData = e.parameter;
if (formData.data) {
data = JSON.parse(formData.data);
values = data.values;
} else {
throw new Error(‘No data provided in postData’);
}
}
} else {
throw new Error(‘No valid postData received’);
}
if (!values || !Array.isArray(values) || values.length === 0) {
throw new Error(‘Parsed data does not contain valid values array.’);
}
const spreadsheet = SpreadsheetApp.openById(SPREADSHEET_ID);
const sheet = spreadsheet.getActiveSheet();
// If the sheet is empty, set up the header row
if (sheet.getLastRow() === 0) {
const headers = [
‘Timestamp’, ‘Page URL’, ‘Domain IP’, ‘Domain Rating’,
‘Referring Domains’, ‘Linked Domains’, ‘Organic Traffic’,
‘Organic Keywords’, ‘Top Country’, ‘Emails’, ‘Contact Page’, ‘Social Links’
];
sheet.getRange(1, 1, 1, headers.length).setValues([headers]).setFontWeight(‘bold’);
}
// Append the new data rows
sheet.getRange(sheet.getLastRow() + 1, 1, values.length, values[0].length).setValues(values);
// Auto-resize columns for better readability
sheet.autoResizeColumns(1, values[0].length);
// Return a success response
return ContentService.createTextOutput(JSON.stringify({
success: true,
message: ‘Data added successfully’,
spreadsheetUrl: spreadsheet.getUrl()
})).setMimeType(ContentService.MimeType.JSON);
} catch (error) {
// Log any errors for debugging
console.error(‘Error in doPost:’, error.toString());
// Return an error response
return ContentService.createTextOutput(JSON.stringify({
success: false,
error: error.toString()
})).setMimeType(ContentService.MimeType.JSON);
}
}
/**
* Handles GET requests to the script URL to confirm it’s running.
*/
function doGet(e) {
return ContentService.createTextOutput(JSON.stringify({
success: true,
message: ‘LinksToro Google Apps Script is running correctly. Ready to receive POST requests.’
})).setMimeType(ContentService.MimeType.JSON);
}
/**
* A utility function to create the spreadsheet and set headers manually if needed.
* To run this, select ‘setupSpreadsheet’ from the function dropdown in the Apps Script editor and click ‘Run’.
*/
function setupSpreadsheet() {
const SPREADSHEET_ID = ‘___’; // Make sure this is the correct ID
const spreadsheet = SpreadsheetApp.openById(SPREADSHEET_ID);
const sheet = spreadsheet.getActiveSheet();
if (sheet.getLastRow() === 0) {
const headers = [
‘Timestamp’, ‘Page URL’, ‘Domain IP’, ‘Domain Rating’,
‘Referring Domains’, ‘Linked Domains’, ‘Organic Traffic’,
‘Organic Keywords’, ‘Top Country’, ‘Emails’, ‘Contact Page’, ‘Social Links’
];
sheet.getRange(1, 1, 1, headers.length).setValues([headers]).setFontWeight(‘bold’);
SpreadsheetApp.flush();
console.log(‘Spreadsheet headers have been set up successfully.’);
} else {
console.log(‘Spreadsheet already has content. Headers were not changed.’);
}
}
- Click the Deploy button and select New deployment.

- In the configuration window, set the following options:
- Type: Select Web app.
- Execute as: Me.
- Who has access: Anyone.

- Click Deploy. You will be asked to authorize the script’s permissions; please approve them.
- After deployment, Google will provide a Web app URL. Copy this URLโyou’ll need it for the final step.

โ Correct URL: https://script.google.com/macros/s/SCRIPT_ID/exec
โ Incorrect URL: https://docs.google.com/spreadsheets/d/SHEET_ID/edit
Connect the Extension to Your Script
- Open the LinksToro extension in your browser and go to the Domain Info tab.
- Find the “Google Sheets URL” field and paste the Web app URL you copied in the previous step.
- Click Test Connection to Worksheet to check if it works.
- The extension will save the URL. The connection is now active! Click the button Add Domain to Worksheet to import domain info to your spreadsheet.

Data Collected
Once connected, the extension will send the following data points to your spreadsheet each time you add a domain:
Column | Description |
Timestamp | The date and time the data was added |
Page URL | The URL of the page that was analyzed |
Domain IP | The IP address of the domain |
Domain Rating | The Ahrefs Domain Rating score |
Referring Domains | Total number of domains linking to the site |
Linked Domains | Total number of domains the site links to |
Organic Traffic | Estimated monthly organic search traffic |
Organic Keywords | Estimated number of keywords the site ranks for |
Top Country | The country that provides the most traffic |
Emails | Any email addresses found on the site |
Contact Page | The URL of the site’s contact page |
Social Links | Links to the site’s social media profiles |
Final words
By completing this setup, you’ve transformed your data collection process. This powerful integration streamlines your workflow, ensuring valuable domain insights are captured automatically in a single, accessible location. You’re now equipped for a more efficient and organized approach to your projects.
Leave a Reply