Matomo React/NextJS site tracking thru GTM

Hi

I’ve been trying to install Matomo tracking on React/NextJS website through Google Tag Manager and it doesn’t seem to work quite as expected. There are suggestions everywhere to use Matomo Tag Manager, but I have numerous tags in GTM as for now, so do not want to change that. And I do not want to install any specific NextJS/React extensions, since tracking should work sufficiently fine with history change.
But it does not.

My setup is that “Matomo Tracking Tag for Matomo Cloud” is launched in GTM wit triggers:

  1. page view
  2. history change

alternatively, I’ve tried a setup as described in the answer below:
(cannot paste link - stackoverflow - google-tag-manager-not-functioning-on-page-change-in-next-js-using-react-gtm-mo )

But the outcome is, the pages are present in the user journey, but the URL and page title does not change. There are eg. 10 pages in the journey, but with same URL and title… (based on “Visits in real-time” report)
Any ideas how to achieve proper tracking of webpage urls and titles?

many thanks,
mike