> For the complete documentation index, see [llms.txt](https://docs.candy-smith.com/main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.candy-smith.com/main/general-info/analytics/custom-events.md).

# custom events

## Adding a new analytics event

The included event list is automatic, but adding a new event requires three changes.

{% stepper %}
{% step %}

### Add the event name

Add the stable event name to:

```
AnalyticsEventNames
```

Example:

```csharp
public const string TutorialCompleted = "tutorial_completed";
```

{% endstep %}

{% step %}

### Add the schema

If Unity Analytics schema provisioning is required, add the event and its parameters to:

```
AnalyticsSchemaCatalog
```

Define:

* event name;
* description;
* parameter names;
* parameter types;
* parameter descriptions.

Parameter names must match the names used by the runtime event.
{% endstep %}

{% step %}

### Emit the event

Send the event from the relevant runtime system through:

```
IAnalyticsService
```

The event is then routed to the selected provider.

Firebase and ByteBrew can send a new generic event without provider-specific mapping.

GameAnalytics sends generic events as design events unless the event requires special progression or ad mapping.
{% endstep %}
{% endstepper %}

After adding a Unity Analytics schema, run:

```
HomeDesignMatch3Kit > Settings > Analytics Schema Setup > Populate Events
```

Run the wizard for every UGS environment where the schema is required.

## Analytics consent

`Enable Analytics` is the main kit-level collection switch.

The game initializes the selected provider and then applies the value of:

```csharp
GameSettings.enableAnalytics
```

For a production privacy flow:

{% stepper %}
{% step %}
Keep analytics disabled before consent.
{% endstep %}

{% step %}
Display the appropriate privacy or consent UI.
{% endstep %}

{% step %}
Enable analytics only after the user grants consent.
{% endstep %}

{% step %}
Disable analytics if consent is rejected or withdrawn.
{% endstep %}
{% endstepper %}

The runtime service exposes:

```csharp
IAnalyticsService.SetDataCollectionEnabled(bool enabled);
```

{% hint style="warning" %}
The kit-level setting does not replace:

* iOS App Tracking Transparency;
* platform privacy requirements;
* Firebase consent configuration;
* advertising network consent requirements.
  {% endhint %}
