Merge pull request #400 from Turqueso/master

Added Google Tag Manager to Google Tools Plugin
This commit is contained in:
Diego Najar 2017-03-19 14:13:14 +01:00 committed by GitHub
commit 4e8c9c9bc6
11 changed files with 67 additions and 17 deletions

View File

@ -6,6 +6,8 @@
}, },
"google-webmasters-tools": "Google Webmasters Tools", "google-webmasters-tools": "Google Webmasters Tools",
"google-analytics-tracking-id": "Google Analytics ID", "google-analytics-tracking-id": "Google Analytics ID",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Gib hier den Google Analytics-Tracking-Code ein, um zu bestätigen, dass die Website Dir gehört.", "complete-this-field-with-the-google-site-verification": "Gib hier den Google Analytics-Tracking-Code ein, um zu bestätigen, dass die Website Dir gehört.",
"complete-this-field-with-the-tracking-id": "Gib hier die Tracking ID ein." "complete-this-field-with-the-tracking-id": "Gib hier die Tracking ID ein.",
"complete-this-field-with-the-tracking-id-google-tag": "Gib hier die Tracking ID ein."
} }

View File

@ -6,6 +6,8 @@
}, },
"google-webmasters-tools": "Google Webmasters Tools", "google-webmasters-tools": "Google Webmasters Tools",
"google-analytics-tracking-id": "Google Analytics ID", "google-analytics-tracking-id": "Google Analytics ID",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Gib hier den Google Analytics-Tracking-Code ein, um zu bestätigen, dass die Website Dir gehört.", "complete-this-field-with-the-google-site-verification": "Gib hier den Google Analytics-Tracking-Code ein, um zu bestätigen, dass die Website Dir gehört.",
"complete-this-field-with-the-tracking-id": "Gib hier die Tracking ID ein." "complete-this-field-with-the-tracking-id": "Gib hier die Tracking ID ein.",
"complete-this-field-with-the-tracking-id-google-tag": "Gib hier die Tracking ID ein."
} }

View File

@ -7,6 +7,8 @@
"google-webmasters-tools": "Google Webmasters tools", "google-webmasters-tools": "Google Webmasters tools",
"google-analytics-tracking-id": "Google Analytics Tracking ID", "google-analytics-tracking-id": "Google Analytics Tracking ID",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Complete this field with the Google Site verification to verify the site owner.", "complete-this-field-with-the-google-site-verification": "Complete this field with the Google Site verification to verify the site owner.",
"complete-this-field-with-the-tracking-id": "Complete this field with the Tracking ID to generate the Javascript tracking code for Google Analytics." "complete-this-field-with-the-tracking-id": "Complete this field with the Tracking ID to generate the Javascript tracking code for Google Analytics.",
"complete-this-field-with-the-tracking-id-google-tag": "Complete this field with the Tracking ID to generate the Javascript tracking code for Google Tag Manager."
} }

View File

@ -6,6 +6,8 @@
}, },
"google-webmasters-tools": "Google Webmasters tools", "google-webmasters-tools": "Google Webmasters tools",
"google-analytics-tracking-id": "Google Analytics Tracking ID", "google-analytics-tracking-id": "Google Analytics Tracking ID",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Complete este campo con el código de verificación de Google Webmasters Tools para verificar la propiedad del sitio.", "complete-this-field-with-the-google-site-verification": "Complete este campo con el código de verificación de Google Webmasters Tools para verificar la propiedad del sitio.",
"complete-this-field-with-the-tracking-id": "Complete este campo con el Tracking ID para generar el código Javascript para trackear el sitio." "complete-this-field-with-the-tracking-id": "Complete este campo con el Tracking ID para generar el código Javascript para trackear el sitio.",
"complete-this-field-with-the-tracking-id-google-tag": "Complete este campo con el Tracking ID para generar el código Javascript para Google Tag Manager."
} }

View File

@ -7,6 +7,8 @@
"google-webmasters-tools": "Google Search Console", "google-webmasters-tools": "Google Search Console",
"google-analytics-tracking-id": "Google Analytics トラッキングID", "google-analytics-tracking-id": "Google Analytics トラッキングID",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Google Seach Consoleがサイト所有権を確認するためのメタタグを入力します。", "complete-this-field-with-the-google-site-verification": "Google Seach Consoleがサイト所有権を確認するためのメタタグを入力します。",
"complete-this-field-with-the-tracking-id": "Google Analyticsがトラッキングをするために生成したトラッキングIDを入力します。" "complete-this-field-with-the-tracking-id": "Google Analyticsがトラッキングをするために生成したトラッキングIDを入力します。",
"complete-this-field-with-the-tracking-id-google-tag": "トラッキングをするために生成したトラッキングIDを入力します。"
} }

View File

@ -7,6 +7,8 @@
"google-webmasters-tools": "Google Webmasters tools", "google-webmasters-tools": "Google Webmasters tools",
"google-analytics-tracking-id": "Google Analytics Tracking ID", "google-analytics-tracking-id": "Google Analytics Tracking ID",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Vul dit veld in met de Google Site verificatie om jezelf te verifiëren als site beheerder.", "complete-this-field-with-the-google-site-verification": "Vul dit veld in met de Google Site verificatie om jezelf te verifiëren als site beheerder.",
"complete-this-field-with-the-tracking-id": "Vul dit veld in met de Tracking ID om de Javascript tracking code te genereren voor Google Analytics." "complete-this-field-with-the-tracking-id": "Vul dit veld in met de Tracking ID om de Javascript tracking code te genereren voor Google Analytics.",
"complete-this-field-with-the-tracking-id-google-tag": "Vul dit veld in met de Tracking ID."
} }

View File

@ -6,6 +6,8 @@
}, },
"google-webmasters-tools": "Google Webmasters tools", "google-webmasters-tools": "Google Webmasters tools",
"google-analytics-tracking-id": "Google Analytics Tracking ID", "google-analytics-tracking-id": "Google Analytics Tracking ID",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Complete this field with the Google Site verification to verify the site owner.", "complete-this-field-with-the-google-site-verification": "Complete this field with the Google Site verification to verify the site owner.",
"complete-this-field-with-the-tracking-id": "Complete this field with the Tracking ID to generate the Javascript tracking code for Google Analytics." "complete-this-field-with-the-tracking-id": "Complete this field with the Tracking ID to generate the Javascript tracking code for Google Analytics.",
"complete-this-field-with-the-tracking-id-google-tag": "Complete this field with the ID"
} }

View File

@ -6,6 +6,8 @@
}, },
"google-webmasters-tools": "Google Webmasters tools", "google-webmasters-tools": "Google Webmasters tools",
"google-analytics-tracking-id": "Google Analytics Tracking ID", "google-analytics-tracking-id": "Google Analytics Tracking ID",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Заполните это поле для проверки владельца сайта.", "complete-this-field-with-the-google-site-verification": "Заполните это поле для проверки владельца сайта.",
"complete-this-field-with-the-tracking-id": "Заполните это поле с Tracking ID чтобы сгенерировать код Javascript для отслеживания в Google Analytics." "complete-this-field-with-the-tracking-id": "Заполните это поле с Tracking ID чтобы сгенерировать код Javascript для отслеживания в Google Analytics.",
"complete-this-field-with-the-tracking-id-google-tag": "Заполните это поле с Tracking ID чтобы сгенерировать код Javascript для."
} }

View File

@ -6,6 +6,8 @@
}, },
"google-webmasters-tools": "Google Webmaster Araçları", "google-webmasters-tools": "Google Webmaster Araçları",
"google-analytics-tracking-id": "Google Analytics İzleme No", "google-analytics-tracking-id": "Google Analytics İzleme No",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Google Site Doğrulama ile bu alanı doldurarak sitenizi doğrulayın", "complete-this-field-with-the-google-site-verification": "Google Site Doğrulama ile bu alanı doldurarak sitenizi doğrulayın",
"complete-this-field-with-the-tracking-id": "Bu alanı İzleme No ile doldurarak Google Analytics için Javascript kodu oluşturun." "complete-this-field-with-the-tracking-id": "Bu alanı İzleme No ile doldurarak Google Analytics için Javascript kodu oluşturun.",
"complete-this-field-with-the-tracking-id-google-tag": "Bu alanı İzleme No ile doldurarak için Javascript kodu oluşturun."
} }

View File

@ -7,6 +7,8 @@
"google-webmasters-tools": "Google Webmasters tools", "google-webmasters-tools": "Google Webmasters tools",
"google-analytics-tracking-id": "КОД відстеження Google Analytics", "google-analytics-tracking-id": "КОД відстеження Google Analytics",
"google-tag-manager": "Google Tag Manager",
"complete-this-field-with-the-google-site-verification": "Заповніть це поле для перевірки власника сайту.", "complete-this-field-with-the-google-site-verification": "Заповніть це поле для перевірки власника сайту.",
"complete-this-field-with-the-tracking-id": "Заповніть це поле для генерації Javascript-коду відстеження у Google Analytics." "complete-this-field-with-the-tracking-id": "Заповніть це поле для генерації Javascript-коду відстеження у Google Analytics.",
"complete-this-field-with-the-tracking-id-google-tag": "Заповніть це поле для генерації Javascript-коду відстеження."
} }

View File

@ -6,7 +6,8 @@ class pluginGoogleTools extends Plugin {
{ {
$this->dbFields = array( $this->dbFields = array(
'tracking-id'=>'', 'tracking-id'=>'',
'google-site-verification'=>'' 'google-site-verification'=>'',
'google-tag-manager'=>''
); );
} }
@ -26,23 +27,52 @@ class pluginGoogleTools extends Plugin {
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-tracking-id').'</div>'; $html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-tracking-id').'</div>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>';
$html .= '<label for="jsgoogle-tag-manager">'.$Language->get('Google Tag Manager').'</label>';
$html .= '<input id="jsgoogle-tag-manager" type="text" name="google-tag-manager" value="'.$this->getDbField('google-tag-manager').'">';
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-tracking-id-google-tag').'</div>';
$html .= '</div>';
return $html; return $html;
} }
public function siteHead() public function siteHead()
{ {
global $Url; global $Url;
if(Text::isEmpty($this->getDbField('google-site-verification')) || !($Url->whereAmI()=='home')) { $html = '';
return false;
if((!empty($this->getDbField('google-site-verification'))) && ($Url->whereAmI()=='home')) {
$html .= PHP_EOL.'<!-- Google Webmasters Tools -->'.PHP_EOL;
$html .= '<meta name="google-site-verification" content="'.$this->getDbField('google-site-verification').'">'.PHP_EOL;
}
if(!(Text::isEmpty($this->getDbField('google-tag-manager')))) {
$html .= PHP_EOL."<!-- Google Tag Manager -->".PHP_EOL;
$html .= "<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':".PHP_EOL;
$html .= "new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],".PHP_EOL;
$html .= "j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=".PHP_EOL;
$html .= "'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);".PHP_EOL;
$html .= "})(window,document,'script','dataLayer','".$this->getDbField('google-tag-manager')."');</script>".PHP_EOL;
$html .= "<!-- End Google Tag Manager -->".PHP_EOL;
} }
$html = PHP_EOL.'<!-- Google Webmasters Tools -->'.PHP_EOL;
$html .= '<meta name="google-site-verification" content="'.$this->getDbField('google-site-verification').'">'.PHP_EOL;
return $html; return $html;
} }
public function siteBodyBegin()
{
if((Text::isEmpty($this->getDbField('google-tag-manager')))) {
return false;
}
$html = '<!-- Google Tag Manager (noscript) -->'.PHP_EOL;
$html .= '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id='.$this->getDbField('google-tag-manager').'" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>'.PHP_EOL;
$html .= '<!-- End Google Tag Manager (noscript) -->'.PHP_EOL;
return $html;
}
public function siteBodyEnd() public function siteBodyEnd()
{ {
$html = PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL; $html = PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL;