Constructor
Learn how to initialize experience metadata directly.
The constructor initializes the experience metadata.
You normally read it from the slot metadata instead, but you can construct it directly to provide fixed metadata in tests.
Signature
The constructor has the following signature:
public function __construct( string $experienceId, string $audienceId, ?ExperimentMetadata $experiment = null,)Example
Here is a basic example of how to initialize experience metadata:
<?phpuse Croct\Plug\Content\ExperienceMetadata;
$metadata = new ExperienceMetadata( experienceId: 'summer-sale', audienceId: 'returning-visitors',);Parameters
The following list describes the supported parameters:
- experienceIdstring
The ID of the experience that served the content.
- audienceIdstring
The ID of the audience the visitor matched.
- experiment(optional)ExperimentMetadata|null
The experiment running within the experience. The default is null, which means no experiment applies.
Default:null