# getVariantId

Learn how to read the ID of the served variant.

This method gives you the ID of the variant served to the visitor.

## Signature

This method has the following signature:

```php
public function getVariantId(): string
```

This method returns the ID of the variant served to the visitor.

## Example

Here is a basic example of how to use this method:

```php
<?php
use Croct\Plug\Croct;
use Croct\Plug\FetchOptions;

$croct = Croct::fromDotenv();
$options = FetchOptions::defaults()->withSchema();
$experiment = $croct->fetchContent('home-banner', $options)->getMetadata()->getExperience()->getExperiment();
$variantId = $experiment->getVariantId();
```
