I have a script running in the onStartup event for all the views in a project to save log data.
The issue is that every time I save a view, and a client is currently on that view, the script fires again, causing fake logs to be saved in the database.
But that isn't going to catch all of the navigation. That event doesn't catch all returns to a view, so is not fit for your stated purpose. You should be instrumenting the actions where navigation is initiated.
Move this to a project script that will take parameters and then when you click on a navigation button or have an action like @pturmel said to navigate run it there. It will be a simple one-liner someScript.logNavigation or something of the sort.