public function addTargetGroupHitScript(FilterResponseEvent $event)
    {
        $request = $event->getRequest();
        $response = $event->getResponse();

        if ($this->preview
            || 0 !== strpos($response->headers->get('Content-Type'), 'text/html')
            || Request::METHOD_GET !== $request->getMethod()
        ) {
            return;
        }

        $script = $this->twig->render('SuluAudienceTargetingBundle:Template:hit-script.html.twig', [
            'url' => $this->targetGroupHitUrl,
            'urlHeader' => $this->urlHeader,
            'refererHeader' => $this->referrerHeader,
            'uuidHeader' => $this->uuidHeader,
            'uuid' => $request->attributes->has('structure') ? $request->attributes->get('structure')->getUuid() : null,
        ]);

        $response->setContent(str_replace(
            '</body>',
            $script . '</body>',
            $response->getContent()
        ));
    }