stfalcon-studio/ab-test-bundle

Symfony AtfalconAbTestBundle

安装: 4

依赖者: 0

建议者: 0

安全: 0

星星: 4

观察者: 14

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2015-02-03 20:10 UTC

This package is not auto-updated.

Last update: 2024-09-18 07:03:52 UTC


README

简单的捆绑包,用于在网站页面添加Google分析A/B测试代码

先决条件

此版本的捆绑包需要

  1. PHP >= 5.3.2
  2. Symfony >= 2.1
  3. SonataAdminBundle >=2.1

安装

安装是一个简单的4步骤过程

  1. 在您的composer.json中添加StfalconAbTestBundle
  2. 启用StfalconAbTestBundle
  3. 导入StfalconAbTestBundle路由并更新您的配置文件
  4. 更新您的数据库模式

步骤1:在您的composer.json中添加StfalconAbTestBundle

{
    "require": {
        "stfalcon-studio/ab-test-bundle": "*"
    }
}

现在运行以下命令让composer下载捆绑包

$ php composer.phar update stfalcon-studio/ab-test-bundle

Composer会将捆绑包安装到项目的vendor/stfalcon目录。

步骤2:启用StfalconAbTestBundle和相关捆绑包

最后,在kernel中启用该捆绑包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        // For SonataAdminBundle
        new Sonata\CoreBundle\SonataCoreBundle(),
        new Sonata\BlockBundle\SonataBlockBundle(),
        new Knp\Bundle\MenuBundle\KnpMenuBundle(),
        new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),
        new Sonata\AdminBundle\SonataAdminBundle(),
        
        new Stfalcon\AbTestBundle\StfalconAbTestBundle(),
        // ...
    );
}

步骤3:更新您的数据库模式

由于添加了新的实体AbTest,捆绑包配置完成后,您需要更新数据库模式。

运行以下命令。

$ php app/console doctrine:schema:update --force

此时,您可以通过访问URL:[http://yoursite.local/admin/dashboard](http://yoursite.local/admin/dashboard)来访问管理仪表板。有关SonataAdminBundle的入门指南,请参阅[http://sonata-project.org/bundles/admin/2-0/doc/reference/getting_started.html](http://sonata-project.org/bundles/admin/2-0/doc/reference/getting_started.html)

步骤4:在模板中添加代码

要在您的页面中添加Google Analytics A/B测试代码,您必须在主模板中的<head>标签后添加以下代码。

{{ init_ab_test() }}

要在网站上添加AbTest,请在管理部分填写表单

页面URL - 想要添加A/B测试代码的页面的URL。例如:/page/some-page-slug

代码 - Google分析A/B测试代码。例如:12345-6

现在,如果您在http://your-project/page/some-page-slug中打开HTML代码的页面,将添加Google分析A/B测试代码

这就完成了!

现在您已经完成了StfalconAbTestBundle的安装和配置!