ezoterik/yii2-google-tag-manager
最新稳定版本:2.3.0
Composer 安装命令:
composer require ezoterik/yii2-google-tag-manager
包简介
Google Tag Manager extension for the Yii2 framework
README 文档
README
Integration Google Tag Manager in your application
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist ezoterik/yii2-google-tag-manager "*"
or add
"ezoterik/yii2-google-tag-manager": "*"
to the require section of your composer.json file.
Setup
Add this code in your @app/config/main.php config file with the other previous config:
'bootstrap' => ['googleTagManager'], 'components' => [ 'googleTagManager' => [ 'class' => 'ezoterik\googleTagManager\GoogleTagManager', 'tagManagerId' => 'GOOGLE_TAG_MANAGER_ID', //Your Google Tag Manager ID without "GTM-" prefix ], ],
Usage
You can generate events:
Yii::$app->googleTagManager->dataLayerPushItemDelay('event', 'example_event');
Or push event as object:
Yii::$app->googleTagManager->dataLayerPushItem(null, (object)[ 'event' => 'view_item', 'ecommerce' => (object)[ 'currency' => 'UAH', 'value' => '500', 'items' => [ (object)[ 'item_name' => 'Product name', 'item_id' => '12345', 'price' => '500', 'item_brand' => 'Analytics', 'item_category' => 'Very Good Category', 'item_category2' => 'Very Good Category 2', 'item_category3' => 'Very Good Category 3', 'item_category4' => 'Very Good Category 4', 'item_variant' => 'full', 'item_list_name' => 'sales', 'item_list_id' => 'sales2022', ], ], ], ]);
统计信息
- 总下载量: 320.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-09