public function activate($experimentKey, $userId, $attributes = null)
    {
        if (!$this->_isValid) {
            $this->_logger->log(Logger::ERROR, 'Datafile has invalid format. Failing "activate".');
            return null;
        }

        if (!$this->validateInputs(
            [
                self::EXPERIMENT_KEY =>$experimentKey,
                self::USER_ID => $userId
            ]
        )
        ) {
            return null;
        }

        $variationKey = $this->getVariation($experimentKey, $userId, $attributes);
        if (is_null($variationKey)) {
            $this->_logger->log(Logger::INFO, sprintf('Not activating user "%s".', $userId));
            return null;
        }

        $this->sendImpressionEvent($experimentKey, $variationKey, $userId, $attributes);

        return $variationKey;
    }
public function activate($experimentKey, $userId, $attributes = null)
    {
        if (!$this->_isValid) {
            $this->_logger->log(Logger::ERROR, 'Datafile has invalid format. Failing "activate".');
            return null;
        }

        if (!$this->validateInputs(
            [
                self::EXPERIMENT_KEY =>$experimentKey,
                self::USER_ID => $userId
            ]
        )
        ) {
            return null;
        }

        $variationKey = $this->getVariation($experimentKey, $userId, $attributes);
        if (is_null($variationKey)) {
            $this->_logger->log(Logger::INFO, sprintf('Not activating user "%s".', $userId));
            return null;
        }

        $this->sendImpressionEvent($experimentKey, $variationKey, $userId, $attributes);

        return $variationKey;
    }
public function activate ( $ experimentKey , $ userId , $ attributes = null ) { if ( ! $ this -> _isValid ) { $ this -> _logger -> log ( Logger :: ERROR , 'Datafile has invalid format. Failing "activate".' ) ; return null ; } if ( ! $ this -> validateInputs ( [ self :: EXPERIMENT_KEY => $ experimentKey , self :: USER_ID => $ userId ] ) ) { return null ; } $ variationKey = $ this -> getVariation ( $ experimentKey , $ userId , $ attributes ) ; if ( is_null ( $ variationKey ) ) { $ this -> _logger -> log ( Logger :: INFO , sprintf ( 'Not activating user "%s".' , $ userId ) ) ; return null ; } $ this -> sendImpressionEvent ( $ experimentKey , $ variationKey , $ userId , $ attributes ) ; return $ variationKey ; }
Buckets visitor and sends impression event to Optimizely.

@param $experimentKey string Key identifying the experiment.
@param $userId string ID for user.
@param $attributes array Attributes of the user.

@return null|string Representing the variation key.
Buckets visitor and sends impression event to Optimizely .