# Constructor

Learn how to initialize experience metadata directly.

The constructor initializes the experience metadata.

You normally read it from the [slot metadata](../slot-metadata/get-experience) instead, but you can construct it directly to provide fixed metadata in tests.

## Signature

The constructor has the following signature:

```php
public function __construct(
    string $experienceId,
    string $audienceId,
    ?ExperimentMetadata $experiment = null,
)
```

## Example

Here is a basic example of how to initialize experience metadata:

```php
<?php
use Croct\Plug\Content\ExperienceMetadata;

$metadata = new ExperienceMetadata(
    experienceId: 'summer-sale',
    audienceId: 'returning-visitors',
);
```

## Parameters

The following list describes the supported parameters:

- `experienceId`: `string`

  The ID of the experience that served the content.

- `audienceId`: `string`

  The ID of the audience the visitor matched.

- `experiment`: `ExperimentMetadata|null` (optional) (default: null) (see [ExperimentMetadata](/reference/sdk/php/api/response/experiment-metadata))

  The experiment running within the experience. The default is `null`, which means no experiment applies.
