Issue Installing GTM on MODX revolution ERROR ...pdotools/pdotools.class.php : 999) Unexpected tag 'w' in head line

47 Views Asked by At

Trying to insert GTM code for MODX revolution into head chunk before closing and I getting white screen in browser and in error log I am getting this. it doesn't like first line of code in GTM:

[2023-09-04 14:50:55] (ERROR @ /var/www/u444/data/www/my-domain.com/core/components/pdotools/model/pdotools/pdotools.class.php : 999) Unexpected tag 'w' in head line 37, near '{w[' <- there in a7079a48faef018b6bba5ad8e296596e line 1, near '{include 'head'' <- there

here is GTM code:

<!-- 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','GTM-FFFFFFF');</script>
<!-- End Google Tag Manager -->

I tried to install GTM snippet to head chunk

2

There are 2 best solutions below

0
Anton Mislawsky On

Solution is easy. Add space or break line symbol after each '{' symbol in GTM code. This solve the problem for me.

0
Anton Tarasov On

Probably you may use Fenom and get some kind of syntax issue, it doesn't like some combinations with curly braces {. You were suggested workable solution above, there is also a good tag for Fenom - wrap your GTM code with {ignore}...{/ignore}, it might help as well