Recently I had set up a new SMF forum (Simplemachines) and wanted to insert the Google tag for Google Analytics.
So I just copied the Google tag and pasted it in the index.template.php file.But unfortunately that didn’t work and all I saw afterwards on the forum was a white page.It took me a while to find the solution.
This is the code you get from Google and it doesn’t work:
For the code to work you have to put a backslash (\) in front of each single quotation mark (‘).
The correct script looks like this:
<!– Google tag (gtag.js) –>
<script async src=”https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX”></script>
window.dataLayer = window.dataLayer || ;
gtag(\’js\’, new Date());
This worked in my case. Let us know if you had success with this solution.