The ordinary approach using file.tags or file.etags will only report any tag used in a given page just once, so you’ll need to go deeper and use some variant of app.metadataCache.getFileCache().tags as illustrated in this post:
I’m a little busy a few days now, but are you able to take it from there, or do you need help with the coding?