Browse Source

ga conversion support

master
filesite 7 hours ago
parent
commit
a4b8dad127
  1. 2
      conf/app.php
  2. 6
      plugins/Html.php

2
conf/app.php

@ -202,7 +202,7 @@ $configs = array( @@ -202,7 +202,7 @@ $configs = array(
//Google Adwords conversion配置
//示例:{'controller': 'xx', 'action': 'yy', 'send_to': 'zzz'}
'GA_MEASUREMENT_CONVERSIONS' => [],
'GA_MEASUREMENT_CONVERSIONS' => array(),
//密码授权默认关闭
"password_auth" => array(

6
plugins/Html.php

@ -125,12 +125,12 @@ eof; @@ -125,12 +125,12 @@ eof;
}
if (!empty(FSC::$app['config']['GA_MEASUREMENT_CONVERSIONS'])) {
$conversions = FSC::$app['config']['GA_MEASUREMENT_CONVERSIONS'];
$conversions = !empty(FSC::$app['config']['GA_MEASUREMENT_CONVERSIONS']) ? FSC::$app['config']['GA_MEASUREMENT_CONVERSIONS'] : array();
if (!empty($conversions)) {
//格式:{'controller': 'xx', 'action': 'yy', 'send_to': 'zzz'}
foreach ($conversions as $item) {
if (FSC::$app['controller'] == $item['controller'] && FSC::$app['action'] == $item['action']) {
gacode .= <<<eof
$gacode .= <<<eof
gtag('event', 'conversion', {'send_to': '{$item['send_to']}'});
eof;

Loading…
Cancel
Save