After attempting to integrate Google Tag Manager into my website, I encountered a strange issue where upon refreshing the page, it would go completely blank with no specific error displayed.
I followed the only upvoted solution from a thread on Stack Overflow that was posted a year ago but without an accepted answer yet: Same question 1year ago. Unfortunately, this solution did not work for me.
I'm at a loss as to what the problem could be as there are no errors showing in the console.
If anyone has any insights or suggestions, please feel free to share them.
Tag for better understanding:
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXX');</script>
<!-- End Google Tag Manager -->
Edit :
Upon testing it on another website, the Google Tag Manager implementation worked seamlessly.
Additional information: When I add the correct Google Tag Manager code to the site I'm working on, viewing the page source reveals a blank page. However, inspecting it shows the following output:
https://i.stack.imgur.com/8EmV4.png
Edit 2 :
The issue seems to stem from the section enclosed within
<noscript><iframe src="">.....</iframe></noscript>
. If I remove the surrounding function tags, the implementation works correctly.
For further details, the website I'm working on is ->
SOLVED
The problem was caused by Smarty, which failed to recognize it as a function. To resolve this, using the {literal}....{/literal}
tags solved the issue.