Update page title tag dynamically

Hi I came across this thread as I was also looking to use custom JS code to update the title given that dynamic meta feature is not working right now.

I added simple javascript code to the workflow so that this code is executed when page loads but unfortunately it is not working right.

Did anybody manage to implement title update with js?

document.addEventListener(“DOMContentLoaded”, function () {
let newTitle = collections[‘67b01ddc-45f7-4613-a3e2-f963549d6f4d’]?.[‘data’]?.[‘office_name’]+ “test”;
document.title = newTitle;
});