Last active
September 18, 2019 07:37
-
-
Save georgringer/0f4f3d0fc7bf6b11668c2a1ac4984a7f to your computer and use it in GitHub Desktop.
Google Tag Manager with CMS 9. The Site module is extended to allow site admins to edit the GTM code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
page { | |
headerData.50 = TEXT | |
headerData.50 { | |
if.isTrue.data = site:googleTagManager | |
stdWrap.replacement { | |
10 { | |
search = ###CODE### | |
replace.data = site:googleTagManager | |
} | |
} | |
value ( | |
<!-- Google Tag Manager --> | |
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': | |
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], | |
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= | |
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); | |
})(window,document,'script','dataLayer','###CODE###');</script> | |
<!-- End Google Tag Manager --> | |
) | |
} | |
3 = TEXT | |
3 { | |
if.isTrue.data = site:googleTagManager | |
stdWrap.replacement { | |
10 { | |
search = ###CODE### | |
replace.data = site:googleTagManager | |
} | |
} | |
value ( | |
<!-- Google Tag Manager (noscript) --> | |
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=###CODE###" | |
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> | |
<!-- End Google Tag Manager (noscript) --> | |
) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# placed in EXT:site/Configuration/SiteConfiguration/Overrides/sites.php | |
defined('TYPO3_MODE') || die('Access denied.'); | |
call_user_func( | |
function ($table) { | |
$GLOBALS['SiteConfiguration'][$table]['columns']['googleTagManager'] = [ | |
'label' => 'Google Tag Manager', | |
'config' => [ | |
'type' => 'input', | |
'placeholder' => 'GTM-123456', | |
], | |
]; | |
$GLOBALS['SiteConfiguration'][$table]['types']['0']['showitem'] .= ',--div--;Custom,googleTagManager'; | |
}, | |
'site' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment