getExperiment
Learn how to read the experiment that served the content.
This method gives you the experiment the visitor was assigned to.
Signature
This method has the following signature:
public function getExperiment(): ?ExperimentMetadataThis method returns the experiment the visitor was assigned to, or null when none was assigned.
Example
Here is a basic example of how to use this method:
<?phpuse Croct\Plug\Croct;use Croct\Plug\FetchOptions;
$croct = Croct::fromDotenv();$options = FetchOptions::defaults()->withSchema();$experience = $croct->fetchContent('home-banner', $options)->getMetadata()->getExperience();$experiment = $experience->getExperiment();