FB: https://developers.facebook.com/docs/marketing-api/conversio...
Google: https://developers.google.com/adwords/api/docs/guides/conver...
This is also why companies like Tealium and Segment are now worth billions of dollars. They provide a single integration point that funnels events to dozens of marketing companies' server-side APIs.