Skip to main content
This topic provides example code that shows how to write an event. On the service, this example code updates event-based stats based on the stat rules that you’ve defined in Partner Center. The following example uses the flat C API. LogToScreen represents your app’s logging function.
For more information, see XblEventsWriteInGameEvent.

Troubleshooting

  • The call returns E_INVALIDARG. xboxLiveContext or the event name is null.
  • The call returns E_XBL_NOT_INITIALIZED. Call XblInitialize before you write events.
  • The call returns E_NOTIMPL. The XGameEvent feature of the Gaming Runtime isn’t available. On a Windows PC, the installed Gaming Runtime Services must include the XGameEvent feature.
  • The call succeeds, but the stat doesn’t change. The event name and the names of the event fields must match the names in your title’s service configuration. Names are case-insensitive. If the event name doesn’t match an event in the service configuration, the service drops the event without notifying your game.
  • Field values are in the wrong place. Put fields that have a finite set of numeric or string values, such as difficulty level or game mode, in the dimensions. Put scalar numeric metrics, such as score, time, or position, in the measurements.
  • Updates take time. Events are written locally on the device, even when the device is offline, and are uploaded when the device is online. If the device is online, event-based stats typically update 5 to 20 seconds after the event is written.
Last modified on October 29, 2026