{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "663b52e3-3baa-40b9-b236-7a2b9bac0f1f",
      "name": "Update Rank & Rating Log",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        820,
        40
      ],
      "parameters": {
        "columns": {
          "value": {
            "rank": "={{ $json.rank }}",
            "rating": "={{ $json.rating }}",
            "keyword": "={{ $('Search Google Play').item.json.search_parameters.q }}",
            "searched_at": "={{ $now.toISO() }}",
            "app_title_to_match": "={{ $('Loop Over Keywords').item.json.app_title_to_match }}"
          },
          "schema": [
            {
              "id": "searched_at",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "searched_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "app_title_to_match",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "app_title_to_match",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "keyword",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rating",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "useAppend": true
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        }
      },
      "credentials": {},
      "typeVersion": 4.5
    },
    {
      "id": "c2840876-46bb-4355-9e89-b90743a5ed4c",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1260,
        115
      ],
      "parameters": {
        "amount": 4
      },
      "typeVersion": 1.1
    },
    {
      "id": "cd4f9a3b-2ef8-4d7d-b016-887a81eda107",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -280,
        115
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 10
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d8f9a1e2-8686-4aef-9ab4-49e694ff494a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 460,
        "content": "## Schedule\n\nConfigured to run at 10 AM UTC every day. Adjust as needed or trigger it manually."
      },
      "typeVersion": 1
    },
    {
      "id": "f6ce04bc-263c-44c6-b650-1b6947c1a1e4",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -100,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 460,
        "content": "## Get Keywords and Titles to Match\n\nReads your Google Sheet to fetch your keywords and app titles to match.\n\nThen loops over each row."
      },
      "typeVersion": 1
    },
    {
      "id": "2c3c0cbb-ff02-488d-b81b-cfac44bcea2a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        540,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 220,
        "height": 460,
        "content": "## Parse Rank & Rating\n\nCode to find and parse target app's rank and rating. Assigns \"N/A\" if an app title is not found in the results."
      },
      "typeVersion": 1
    },
    {
      "id": "52f66150-7693-4a10-9751-f753a97de6d1",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        320,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 460,
        "content": "## Search Google Play\n\nSearches keyword in SerpApi's Google Play Store API."
      },
      "typeVersion": 1
    },
    {
      "id": "f4ea5441-9de0-42a2-9dea-aa545c23f18e",
      "name": "Get Keywords and Titles to Match",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -60,
        115
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        }
      },
      "credentials": {},
      "typeVersion": 4.5
    },
    {
      "id": "68f1519c-061d-4a95-8d45-f79ff7082ec6",
      "name": "Loop Over Keywords",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        160,
        120
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "7c9a95f8-5e5e-44e3-a6ec-9eeb014ec3c7",
      "name": "Search Google Play",
      "type": "n8n-nodes-serpapi.serpApi",
      "position": [
        380,
        40
      ],
      "parameters": {
        "q": "={{ $json.keyword }}",
        "operation": "google_play",
        "requestOptions": {},
        "additionalFields": {}
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "ab545189-47c1-4074-ba76-020667b0101c",
      "name": "Parse Rank & Rating for Target App",
      "type": "n8n-nodes-base.code",
      "position": [
        600,
        40
      ],
      "parameters": {
        "jsCode": "index = $input.first().json.organic_results[0].items.findIndex(obj => obj.title.includes($('Loop Over Keywords').first().json.app_title_to_match));\n\nif (index >= 0) {\n  rank = index + 1;\n  rating = $input.first().json.organic_results[0].items[index].rating\n} else {\n  rank = \"N/A\"\n  rating = \"N/A\"\n}\n\nreturn {\n  rank: rank,\n  rating: rating\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "f92cd971-38f9-4878-896b-a0781fee0f60",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        780,
        -460
      ],
      "parameters": {
        "width": 440,
        "height": 740,
        "content": "## Update Google Sheet\n\nLogs results to results log and updates last run overview sheet.\n\nAdd your own Google Sheet here.\n\nIf the mappings get wiped when you add your Google Sheet, here they are:\n\nsearched_at: `{{ $now.toISO() }}`\napp_title_to_match: `{{ $('Loop Over Keywords').item.json.app_title_to_match }}`\nkeyword: `{{ $('Search Google Play').item.json.search_parameters.q }}`\nrank: `{{ $json.rank }}`\nrating: `{{ $json.rating }}`\n\nThe update last run node should match on `title_keyword_pair`. Enter this expression to match on:\n\n`{{ $('Loop Over Keywords').item.json.title_keyword_pair }}`"
      },
      "typeVersion": 1
    },
    {
      "id": "3ed6ab74-e07f-4b8c-a57b-6f918204bba9",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1240,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 200,
        "height": 460,
        "content": "## Delay\n\nWait 4 seconds before going to next row to not hit Google Sheets API's per minute quota limit. You can remove/adjust this if you have a a higher quota limit on the Google Sheets API. "
      },
      "typeVersion": 1
    },
    {
      "id": "958079ab-11a4-464b-8a7d-fc832083bf5e",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -860,
        -420
      ],
      "parameters": {
        "width": 520,
        "height": 1040,
        "content": "## Google Play Store App Rank and Rating Monitoring\n\n### What and who this is for\n\nThis workflow will be useful for anyone looking to do SEO tracking on the Google Play Store. It automates checking Google Play Store rank positions and average ratings for a list of app titles.\n\nThe SerpApi component can also be modified to use other APIs for anyone looking for SEO tracking on any other search engine supported by SerpApi.\n\n### How it works\n\nThis workflow takes in a list of keywords and app titles to identify the apps' rank in Google Play Store search results. It also grabs the average rating of the app. The search uses SerpApi's Google Play Store API.\n\nThe results are then synced to two different sheets in a Google Sheet. The first is a log of all past run. The latest results are appended to the bottom of the log. The second updates a kind of \"dashboard\" to show the results from the latest run.\n\nThe workflow includes a Wait node that delays 4 seconds between each app title and keyword pair to prevent hitting the default Google Sheets' API per minute rate limit. You can delete this if you have a high enough custom rate limit on the Google Sheets API.\n\nThe Schedule Trigger is configured to run at 10 AM UTC every day.\n\n### How to use\n\n1. Create a free SerpApi account here: https://serpapi.com/\n1. Add SerpApi credentials to n8n. Your SerpApi API key is here: https://serpapi.com/manage-api-key\n1. Connect your Google Sheets accounts to n8n. Help available here: https://n8n.io/integrations/google-sheets/\n1. Copy this Google Sheet to your own Google account: https://docs.google.com/spreadsheets/d/1DiP6Zhe17tEblzKevtbPqIygH3dpPCW-NAprxup0VqA/edit?gid=1750873622#gid=1750873622\n1. Set your own list of keywords and app titles to match in the 'Latest Run' sheet. This is the source list used to run the searches and must be set.\n1. Connect your Google Sheet in the 'Get Keywords and Titles to Match' Google Sheet node\n1. Connect your Google Sheet in the 'Update Rank & Rating Log' Google Sheet node\n1. Connect your Google Sheet again in the 'Update Latest Run' Google Sheet node\n1. (Optional) Update the schedule or disable the schedule to only run manually\n\n### Documentation\n\n[SerpApi Google Play Store API](https://serpapi.com/google-play-api)\n[SerpApi n8n Node Intro Guide](https://serpapi.com/blog/boost-your-n8n-workflows-with-serpapis-verified-node/)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "dd0c2409-a2d4-49d4-81eb-9124d7628957",
      "name": "Update Latest Run",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1040,
        40
      ],
      "parameters": {
        "columns": {
          "value": {
            "rank": "={{ $('Parse Rank & Rating for Target App').item.json.rank }}",
            "rating": "={{ $('Parse Rank & Rating for Target App').item.json.rating }}",
            "keyword": "={{ $('Loop Over Keywords').item.json.keyword }}",
            "searched_at": "={{ $now.toISO() }}",
            "app_title_to_match": "={{ $('Loop Over Keywords').item.json.app_title_to_match }}",
            "title_keyword_pair": "={{ $('Loop Over Keywords').item.json.title_keyword_pair }}"
          },
          "schema": [
            {
              "id": "app_title_to_match",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "app_title_to_match",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "keyword",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "keyword",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "title_keyword_pair",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "title_keyword_pair",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rank",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "rank",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "rating",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "searched_at",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "searched_at",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "string",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "title_keyword_pair"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "url",
          "value": ""
        },
        "documentId": {
          "__rl": true,
          "mode": "url",
          "value": ""
        }
      },
      "credentials": {},
      "typeVersion": 4.5
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get Keywords and Titles to Match",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Latest Run": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Keywords": {
      "main": [
        [],
        [
          {
            "node": "Search Google Play",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Google Play": {
      "main": [
        [
          {
            "node": "Parse Rank & Rating for Target App",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Rank & Rating Log": {
      "main": [
        [
          {
            "node": "Update Latest Run",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Keywords and Titles to Match": {
      "main": [
        [
          {
            "node": "Loop Over Keywords",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Rank & Rating for Target App": {
      "main": [
        [
          {
            "node": "Update Rank & Rating Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}