Yii 2.0: yii2-analytics-js

Analytics.js binding for Yii2
2 followers

Yii2 Analytics.js Integration

This extension provides Analytics.js integration for Yii Framework 2, and is the natural extension of EAnalytics which performs the same task for Yii1. This extension enables you to control and manage your analytics providers from within your Yii2 configuration, or in more complex examples, from a dynamic configuration.

For licensing information see LICENSE.md.

Travis CI Packagist Version Downloads License Yii2


Source code is available on Github.

For more extensions, tutorial, and others news can be found on my blog: https://www.erianna.com.

Installation

The preferred way to install this extension is through composer.

composer require --prefer-dist "charlesportwoodii/yii2-analytics.js"

or add the following to your composer.json's require-dev section.

"charlesportwoodii/yii2-analytics.js": "~1.0.0"

Configuration

To use this configuration, add the following to your config/web.php configuration file:

return [
    // [...],
    'components' => [
        'analyticsjs' => [
            'class' => 'charlesportwoodii\analytics\AnalyticsJs',
            'providers' => [

            ]
        ]
    ]   
];

A full list of providers and their arguments can be found on the Analytics.js integrations page. This extension directly passes the provider list and arguments to analytics.js.

Examples

Google Analytics

return [
    // [...],

    'components' => [
        // [...],

        'analyticsjs' => [
            'class' => 'charlesportwoodii\analytics\AnalyticsJs',
            'providers' => [
                // Google Analytics Provider
                'Google Analytics' => [
                    'domain'                    => 'https://www.example.com',
                    'doubleClick'               => false,
                    'enhancedLinkAttribution'   => false,
                    'trackingId'                => 'UA-XXXXXXXX',
                    'universalClient'           => 1
                ],

                // Piwik provider
                'Piwik' => [
                    'siteId'                    => 5,
                    'url'                       => 'https://piwik.example.com'
                ]           
            ]
        ]
    ]   
];

Be the first person to leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet