My goal is to develop an application similar to Google Analytics. I have sourced the Analytics.js code from Segment (an open-source analytics platform available at Segment.com) which includes all the necessary functions for tracking user events. Additionally, I have implemented async code to load Analytics.js into my website. However, I am currently facing a challenge. How can I gather these event details happening on my website and transmit them to my own server?