public function setTargetGroup(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        if ($targetGroupId = $request->headers->get($this->targetGroupHeader)) {
            $this->targetGroupStore->setTargetGroupId($targetGroupId);
        } elseif ($targetGroupId = $request->cookies->get($this->targetGroupCookie)) {
            $visitorSession = $request->cookies->get($this->visitorSessionCookie);
            if ($visitorSession) {
                $this->targetGroupStore->setTargetGroupId($targetGroupId);

                return;
            }

            $targetGroup = $this->targetGroupEvaluator->evaluate(
                TargetGroupRuleInterface::FREQUENCY_SESSION,
                $this->targetGroupRepository->find($targetGroupId)
            );

            if ($targetGroup) {
                $this->targetGroupStore->updateTargetGroupId($targetGroup->getId());
            }
        } elseif ($request->getPathInfo() !== $this->targetGroupUrl) {
            // this should not happen on the endpoint for the cache, because it is set there manually as a header
            $targetGroup = $this->targetGroupEvaluator->evaluate();

            $targetGroupId = 0;
            if ($targetGroup) {
                $targetGroupId = $targetGroup->getId();
            }

            $this->targetGroupStore->updateTargetGroupId($targetGroupId);
        }
    }