Thanks for your continued engagement on this post!
So we are using at.js v2, and I had all the code, and some additional personalization, set up on the page view (for this example we will say the view is for a contact page, with the view being equal to 'Contact').
Currently I have the code for tracking time, and some personalization set up on the 'Contact' view, and I also have a copy of the code modification which is on the Page Load Event. I also have the Activity Location set up to 'https://www.sitename.com/contact or any page that starts with https://www.sitename.com'. And with this current implementation if I first land on the homepage (or any page other than the Activity page) I can see that the code runs, and when I navigate to to Contact page, I can see the personalization I set up, but it seems the code does not run. However, if I refresh the Contact page, I see the code runs. Another scenario showing issues is that when I land directly on the Contact page, I see the code runs and the personalization is present. But when I navigate away from the page, and then back to it, the code does not run when the page loads but the personalization is still there. The code only runs after a page refresh.
I understand that is a lot, but if you have any insights at all as to things that can be attempted to try and resolve this I will be forever grateful.
If the personalisation works but the code doesn't then how about if you put a simple console log statement in your Custom Code modification, does that execute successfully when you navigate away from the page and then back to it? If that works then it suggests there's something within your time tracking code that's not working, if that doesn't work then it's likely a more fundamental issue with implementation.