When I try to use Google site tags in the Nicepage Site Settings -> HTML -> Additional Head HTML, the resulting page ends up erroring in the developer tools -> inspection -> Console errors.
tag error 1 -> (index):5687 Uncaught ReferenceError: gtag is not defined
tag error 2 -> GET https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXX
This is the code used (with some omissons on the actual tag ID:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-XXXXXXXX');
gtag('event', 'conversion', {'send_to': 'AW-XXXXXXXX/9NiBCMOXXXXXXXXxz26ac9'});
I have reviewed the answer to this post below, but I did already test this with the comments removed (as seen above):
https://nicepage.com/questions/93052/adding-html-script-to-the-site-settings-html
When I remove from Nicepage and put it directly in the theme header.php file, it works fine without the same console errors. This seems to indicate that Nicepage is not properly handling the somehow.
When I try to use Google site tags in the Nicepage Site Settings -> HTML -> Additional Head HTML, the resulting page ends up erroring in the developer tools -> inspection -> Console errors. tag error 1 -> (index):5687 Uncaught ReferenceError: gtag is not defined tag error 2 -> GET https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXX This is the code used (with some omissons on the actual tag ID: window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-XXXXXXXX'); gtag('event', 'conversion', {'send_to': 'AW-XXXXXXXX/9NiBCMOXXXXXXXXxz26ac9'}); I have reviewed the answer to this post below, but I did already test this with the comments removed (as seen above): https://nicepage.com/questions/93052/adding-html-script-to-the-site-settings-html When I remove from Nicepage and put it directly in the theme header.php file, it works fine without the same console errors. This seems to indicate that Nicepage is not properly handling the somehow.Last edited 05 March 2024 by Support Team