History change get new page title

We have a page where the content gets changed via JS without reloading the page. So none of these actions are tracked by default.
I added a trigger with the Tag Manager that tracks history change (change of current url).
I configured the tag as pageview and as custom url I’ve set {{HistoryHashNewUrl}}. Without the variable it would still show the wrong url.

The only problem now is: Together with the url, also the title of the page changes. But matomo only logs the “old” / default title, not the new one like with the url.
Any suggestions for that to get the new title?

Thanks!

You need to use the {{PageTitle}} variable as the Custom Title, just like you’ve used {{HistoryHashNewUrl}} as the Custom URL.