shapecode / piwik-bundle

此包已被废弃,不再维护。作者建议使用 shapecode/matomo-bundle 包。

此包提供了piwik功能。

安装: 57

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

公开问题: 0

类型:symfony-bundle

1.0.0 2017-07-24 13:58 UTC

This package is auto-updated.

Last update: 2022-02-01 13:08:47 UTC


README

A Symfony2 Bundle that helps you to use the Piwik Open Analytics Platform with your project.

它包含一个Twig函数,可以将跟踪代码插入到您的网站中。此外,您可以通过简单的配置开关将其关闭,以便不在开发环境中跟踪。

安装

只需将以下内容添加到您的composer.json文件中(见 https://getcomposer.org.cn/

"require": {
    "shapecode/piwik-bundle": "~1.0"
}

并在 app/AppKernel.php 中启用此包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Shapecode\Bundle\PiwikBundle\ShapecodePiwikBundle(),
    );
}

使用

在您的视图中的某个位置,在 </body> 标签之前插入

{{ piwik() }}

这将添加适当的Piwik跟踪代码,如API参考中所述。

如果需要,您可以在运行时更改配置

{{ piwik({
    site_id: 1,
    host_name: 'my.piwik.hostname'
    host_path: '/sub_directory/',
    no_script_tracking: false
}) }}

配置

您可以在您的 config.yml 中配置此包。完整示例

shapecode_piwik:
    site_id: 1                      # required, no default. site id from piwik tool
    disabled: %kernel.debug%        # not required, default %kernel.debug%. Usually, you only want to include the tracking code in a production environment
    host_name: my.piwik.hostname    # required. no default. Hostname to the piwik instance.
    host_path: "/sub_directory/"    # not required, default null. Path to the tracking script on the host.
    no_script_tracking: true        # not required, default true. Enables Image-Tracking if JavaScript is disabeld.

致谢、版权和许可证

版权所有 2017 shapecode。代码在 MIT许可证 下发布。

原始脚本来自 http://www.webfactory.de