You’ve linked to documentation for a method you’re not using - you’re getting a structured event because you’re using the trackStructEvent method. You just need to use the setUserId method, from the documentation you’ve linked.
It worked for getting the user_id field in the events table filled in with our customer_id, but they where still struct events and no page_views. Do you have an idea to get this added to the page_view?
The first way is best - just set the userid before you send the event.
The second way would also work if you had uploaded a schema to send it as a custom context but the first option is much simpler.
To explain a little more what’s going on here - the setUserid() method will assign a userid to a persistent object. Once it’s set all subsequent events will have the userid field set.
In general, if it’s a userid that you always have available, it’s best to set it right after tracker initialisation. If it’s a userid you’ll only have when a user signs in, it’s best to assign it at the point of signing in. You can choose to unassign it (by setting it to an empty string or null) when they sign out or not depending on your use case.