Thanks Gary.
With the supplied code I am now getting the following error in the store error logs.
[19-Sep-2024 18:20:12 Europe/London] PHP Parse error: Invalid body indentation level (expecting an indentation level of at least 2) in /home/####/####/includes/hooks/shop/siteWide/gtag.php on line 17
The error is breaking the website and showing a white page and a page not working error.
Line 17 as in the code supplied is
<!-- Google tag (gtag.js) -->
I read online that there should be no indent, which there isn't so I am totally confused by the error that says there should be.
Here is the code that I now have
Code: Select all
class hook_shop_siteWide_gtag {
function listen_injectSiteStart() {
$gtag = <<<gtag
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-###"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '###');
</script>
gtag;
return $gtag;
}
}