{
  "id": "jjJcvWbiUBquRJ0f",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Pull new backlinks to Google Sheets with DataForSEO and get an email report",
  "tags": [],
  "nodes": [
    {
      "id": "6eb9056e-89d7-4662-ae20-b95a94dae4c3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -208,
        -128
      ],
      "parameters": {
        "color": 6,
        "width": 1120,
        "height": 352,
        "content": "## Get new backlinks with DataForSEO\nCreate a DataForSEO connection, specify a Target Domain, and set up additional parameters if needed."
      },
      "typeVersion": 1
    },
    {
      "id": "1a948938-98bc-43d2-9ad2-96919090c382",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -384,
        48
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0208977d-a647-4e3a-820c-4374898dae99",
      "name": "Create spreadsheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -368,
        512
      ],
      "parameters": {
        "title": "=New Backlinks to  {{ $('Get new backlinks').item.json.tasks[0].data.target }} - {{ $now.format(\"yyyy-MM-dd\") }}",
        "options": {},
        "resource": "spreadsheet",
        "sheetsUi": {
          "sheetValues": [
            {
              "title": "New Backlinks"
            }
          ]
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "e1cb44b8-35d5-4a06-9fdf-2dd03fbe324b",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        976,
        512
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Target",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Target",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backlink",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Backlink",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Spam Score",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Spam Score",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backlink Rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Backlink Rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Domain from",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Domain from",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Domain from Rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Domain from Rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL from",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "URL from",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "URL from Rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "URL from Rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backlink Is Broken",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Backlink Is Broken",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Backlinks Is Dofollow",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Backlinks Is Dofollow",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create spreadsheet').item.json.sheets[0].properties.sheetId }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create spreadsheet').item.json.spreadsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5efea612-1094-429d-9bf4-960678cbc40b",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1200,
        512
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "c171439f-f390-4546-88ab-f14d31f412c4",
      "name": "Send a message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1408,
        512
      ],
      "parameters": {
        "sendTo": "user@example.com",
        "message": "=<html> <body> <p>Here is your dayly new backlinks report for {{ $('Get new backlinks').item.json.tasks[0].data.target }}.</p>  <p>During the past day, we identified {{ $('Get new backlinks').item.json.tasks[0].result[0].total_count }} backlinks.</p>  You can review the full list here: <a href=\"{{ $('Create spreadsheet').item.json.spreadsheetUrl }}\">New Backlinks to  {{ $('Get new backlinks').item.json.tasks[0].data.target }} - {{ $now.format(\"yyyy-MM-dd\") }}</a> </body> </html>",
        "options": {},
        "subject": "=New Backlinks to {{ $('Get new backlinks').item.json.tasks[0].data.target }} - {{ $now.format(\"yyyy-MM-dd\") }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "5b6e819f-7609-466b-9700-e2e167f617ac",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        320
      ],
      "parameters": {
        "color": 6,
        "width": 2160,
        "height": 384,
        "content": "## Create a Google Sheet with new backlinks and send it via email\nCreate a Google Sheets connection.\nCreate a Gmail connection and set a receiver."
      },
      "typeVersion": 1
    },
    {
      "id": "761070c8-362b-4262-9ac0-8f3b6ae00c00",
      "name": "Initialize \"items\" field",
      "type": "n8n-nodes-base.set",
      "position": [
        -160,
        48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "0126c659-03a5-4fc8-bd76-62d2ecea1195",
              "name": "items",
              "type": "array",
              "value": "={{ [] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "3f805fb6-3529-475a-b7b5-176b52eb841e",
      "name": "Set \"items\" field",
      "type": "n8n-nodes-base.set",
      "position": [
        64,
        48
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4b3c95a2-4e38-4e37-8e2f-a7e4544808d6",
              "name": "items",
              "type": "array",
              "value": "={{ $json.items }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "e39fc8f1-2118-40bb-b364-6d427c55a8ad",
      "name": "Get new backlinks",
      "type": "n8n-nodes-dataforseo.dataForSeoBacklinksApi",
      "position": [
        288,
        -32
      ],
      "parameters": {
        "limit": 1000,
        "offset": "={{ $runIndex * 1000 }}",
        "target": "=dataforseo.com",
        "filters": "=[\"first_seen\", \">\", \"{{ $now.minus(1, \"days\").format(\"yyyy-MM-dd\") }}\"]",
        "operation": "get-backlinks",
        "include_indirect_links": false
      },
      "credentials": {
        "dataForSeoApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "54061afe-abd8-4f72-a3f1-a3ba70ae1fca",
      "name": "Merge \"items\" with DFS response",
      "type": "n8n-nodes-base.set",
      "position": [
        512,
        -32
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ddd82419-e43e-44d8-919c-2d6602704da5",
              "name": "items",
              "type": "array",
              "value": "={{ [ ...$('Set \"items\" field').item.json.items, ...$json.tasks[0].result[0].items] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "40c3e866-9d94-4880-826b-36f56995680d",
      "name": "Has more pages?",
      "type": "n8n-nodes-base.if",
      "position": [
        736,
        48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cd5943f7-df0b-4329-8436-9a1af3ec7caf",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $runIndex }}",
              "rightValue": "={{ $('Get new backlinks').item.json.tasks[0].result[0].total_count / 1000 - 1}}"
            },
            {
              "id": "9cd8ede8-c09a-4cbc-8050-5d23989ee07e",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "leftValue": "={{ $runIndex }}",
              "rightValue": 5
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "92bd880e-3ba4-4e8b-87c8-ce545ca075ea",
      "name": "Filter (has new backlinks)",
      "type": "n8n-nodes-base.filter",
      "position": [
        -592,
        512
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "648f4d1e-367c-41b2-b223-1363dadc2cc8",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('Get new backlinks').item.json.tasks[0].result[0].total_count }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "2a10e79f-f4be-4af3-bf80-5a8d23090667",
      "name": "Append columns",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        80,
        512
      ],
      "parameters": {
        "columns": {
          "value": {},
          "schema": [],
          "mappingMode": "autoMapInputData",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create spreadsheet').item.json.sheets[0].properties.sheetId }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Create spreadsheet').item.json.spreadsheetId }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "84ed3b69-21f6-4253-b1ad-f2157b664bdf",
      "name": "Set final \"items\" field",
      "type": "n8n-nodes-base.set",
      "position": [
        304,
        512
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "1e2c8353-5628-4948-abe6-35f8d0f660a5",
              "name": "items",
              "type": "array",
              "value": "={{ [...$('Set \"items\" field').item.json.items, ... $('Get new backlinks').item.json.tasks[0].result[0].items]}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "909015f2-a75e-4f20-baa6-f4f3c286dd72",
      "name": "Split out items",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        528,
        512
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "items"
      },
      "typeVersion": 1
    },
    {
      "id": "b9a7e47a-8f84-4233-9c4f-1cb85ed31a0e",
      "name": "Prepare data for Google Sheets",
      "type": "n8n-nodes-base.set",
      "position": [
        752,
        512
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={\n  \"Date\": \"{{ $now.format('yyyy-MM-dd') }}\",\n  \"Target\": \"{{ $('Get new backlinks').item.json.tasks[0].data.target }}\",\n  \"Backlink\": \" {{ $json.url_to }}\",\n  \"Spam Score\": \"{{ $json.backlink_spam_score }}\",\n  \"Backlink Rank\": \"{{ $json.rank }}\",\n  \"Domain from\": \"{{ $json.domain_from }}\",\n  \"Domain from Rank\": \"{{ $json.domain_from_rank }}\",\n  \"URL from\": \"{{ $json.url_from }}\",\n  \"URL from Rank\": \"{{ $json.page_from_rank }}\",\n  \"Backlink Is Broken\":\"{{ $json.is_broken }}\",\n  \"Backlinks Is Dofollow\":\"{{ $json.dofollow }}\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "e33bb7a2-1920-46cf-ab2a-3ab0dd787b0f",
      "name": "Prepage columns for Google Sheets",
      "type": "n8n-nodes-base.set",
      "position": [
        -144,
        512
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"Date\": \"\",\n  \"Target\": \"\",\n  \"Backlink\": \"\",\n  \"Spam Score\": \"\",\n  \"Backlink Rank\": \"\",\n  \"Domain from\": \"\",\n  \"Domain from Rank\": \"\",\n  \"URL from\": \"\",\n  \"URL from Rank\": \"\",\n  \"Backlink Is Broken\":\"\",\n  \"Backlinks Is Dofollow\":\"\"\n}\n"
      },
      "typeVersion": 3.4
    },
    {
      "id": "c5a50579-d94d-4a21-b706-bee6e5dee2d0",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1120,
        -112
      ],
      "parameters": {
        "width": 432,
        "height": 544,
        "content": "This workflow runs once per day and uses the DataForSEO Backlinks API to automatically retrieve newly detected backlinks for your domain or specific URL. Each daily report includes important backlink metrics such as the referring page, referring domain, spam score, domain rating (DR), and whether a link is dofollow.\n\n## How it works\n1. Triggers automatically on a daily schedule.\n2. Fetches backlinks for your target domain or URL using the DataForSEO Backlinks API.\n3. Extracts newly discovered backlinks and their key metrics.\n4. Creates or updates a Google Sheets report with the latest data.\n5. Sends an automated email with a direct link to your report.\n\n## Setup steps\n1. Create or select your DataForSEO connection (use [your API login and password](https://app.dataforseo.com/api-access)).\n2. Enter the domain or URL you want to monitor.\n3. Connect Google Sheets to store your backlink results.\n4. Connect Gmail and define the recipient email address.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "953cd769-0e2e-4eb0-bad4-b52aaac7fd59",
  "connections": {
    "Aggregate": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append columns": {
      "main": [
        [
          {
            "node": "Set final \"items\" field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has more pages?": {
      "main": [
        [
          {
            "node": "Set \"items\" field",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Filter (has new backlinks)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split out items": {
      "main": [
        [
          {
            "node": "Prepare data for Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Initialize \"items\" field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get new backlinks": {
      "main": [
        [
          {
            "node": "Merge \"items\" with DFS response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set \"items\" field": {
      "main": [
        [
          {
            "node": "Get new backlinks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create spreadsheet": {
      "main": [
        [
          {
            "node": "Prepage columns for Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set final \"items\" field": {
      "main": [
        [
          {
            "node": "Split out items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Initialize \"items\" field": {
      "main": [
        [
          {
            "node": "Set \"items\" field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter (has new backlinks)": {
      "main": [
        [
          {
            "node": "Create spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare data for Google Sheets": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge \"items\" with DFS response": {
      "main": [
        [
          {
            "node": "Has more pages?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepage columns for Google Sheets": {
      "main": [
        [
          {
            "node": "Append columns",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}