public function addPiwikCode(ViewEvent $event)
    {
        $model = $event->getModel();
        if (! $model instanceof \Zend\View\Model\ViewModel) {
            return;
        }

        // Return if this is a subrenderer. Therefore we only render once!
        $options = $model->getOptions();
        if (array_key_exists('has_parent', $options) && $options['has_parent']) {
            return;
        }

        $renderer = $event->getRenderer();
        if (! $renderer instanceof \Zend\View\Renderer\PhpRenderer) {
            return;
        }

        $config         = $this->serviceManager->get('config');
        $piwikConfig    = $config['orgHeiglPiwik'];

        $code = str_replace(array_map(function($e){
            return '%%' . $e . '%%';
        }, array_keys($piwikConfig)), array_values($piwikConfig), $this->template);

        $renderer->headScript()->appendScript('//<![CDATA[' . "\n" . $code . "\n" . '//]]>');

        return $renderer;
    }