Keeping track of originating taxonomy

Hi!
When displaying a single content page, I would like to take note of which taxonomy user came from, so that

  • User can navigate to the next item within the same taxonomy
  • I can highlight the relevant taxonomy menu item from within the single layout

I’m building a gallery website where each page belongs to one or multiple taxonomies. Users browse pages entirely using the taxonomy layout. There is only one category and its list is not made available, except for manually crafting the URL

To give you a concrete example: there is only one category art. Users navigate to baseURL/art/title from either
baseURL/tags/tag1 or baseURL/tags/tag2. I need to know whether user came from tag1 or tag2. For example, by using URL like baseURL/art/title/tag1 or baseURL/art/title?tag=tag1

Is it possible to preserve the taxonomy? If not yet, I would be happy to contribute to hugo. Which approach is the best?

Thank you