> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XGameEventWrite

> XGameEventWrite

# XGameEventWrite

Write an in-game event that optionally includes "dimensions" and "measurement" data fields.

## Syntax

```cpp theme={null}
HRESULT XGameEventWrite(  
         XUserHandle user,  
         const char *serviceConfigId,  
         const char *playSessionId,  
         const char* eventName,  
         const char* dimensionsJson,  
         const char* measurementsJson  
)  
```

### Parameters

*user*   \_In\_\
Type: XUserHandle

The User handle to send the event on behalf of.

\**serviceConfigId*   \_In\_z\_\
Type: char

The XBOX Live service config ID (SCID) for this title.

\**playSessionId*   \_In\_z\_\
Type: char

Play Session ID.  This is a unique GUID created by the game at the start of each game session to track the set of events sent in a single play session.

*eventName*   \_In\_z\_\
Type: char\*

Event name.

*dimensionsJson*   \_In\_opt\_z\_\
Type: char\*

Dimensions data fields in JSON format.

*measurementsJson*   \_In\_opt\_z\_\
Type: char\*

Measurement data fields in JSON format.

### Return value

Type: HRESULT

Returns S\_OK if successful; otherwise, returns an error code.  For a list of error codes, see [Error Codes](/reference/errorcodes).

## Remarks

<Note>This function isn't safe to call on a time-sensitive thread. For more information, see [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads).</Note>

Dimensions include event fields with a finite number of defined numeric or string values. Examples of dimensions: map id, difficulty level, character or weapon class, game mode, boolean settings, etc. Measurements include event fields that represent scalar numeric metrics. Examples of measurements: score, time, counters, position, etc. Example: for an in-game event that tracks the highest match score for a difficulty level: The difficulty level should be included in dimensions, and the score should be included in measurements. The name of the event, and the names of the event fields in both dimensions and measurements, must match the names declared in the title's service configuration. The names are case insensitive. If the API writes an event with a name that does not match a name in the service configuration, the service drops the event with no notification.

<Note>Measurements can only have numerical values, while Dimensions can have a wider variety of types. If preferred, the *dimensionsJson* field can be used exclusively for writing events.</Note>

## Requirements

**Header:** XGameEvent.h

**Library:** xgameruntime.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## Conceptual documentation

* [Time-sensitive threads](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## See also

[XGameEvent](/reference/system/xgameevent/xgameevent_members)


## Related topics

- [XGameEvent](/reference/system/xgameevent/xgameevent_members.md)
- [XblEventsWriteInGameEvent](/reference/live/xsapi-c/events_c/functions/xbleventswriteingameevent.md)
- [Sending an event](/services/xbox-services/player-data/stats-leaderboards/event-based/events/how-to/live-sending-an-event.md)
- [PFEventsWriteEventsRequest](/services/playfab/api-references/c/pfeventstypes/structs/pfeventswriteeventsrequest.md)
- [PFEventsWriteEventsResponse](/services/playfab/api-references/c/pfeventstypes/structs/pfeventswriteeventsresponse.md)
