|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
terryjackson Smarty n00b
Joined: 24 Feb 2018 Posts: 2
|
Posted: Sat Feb 24, 2018 6:02 am Post subject: Smarty error when Google Analytics code is installed |
|
|
Hi,
My website is working fine but when I add Google Analytics code between <header> and </header> tags and then website goes down.
header.tpl
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-11468xxxx-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-11468xxxx-1');
</script>
Google Analytics Code
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-11468xxxx-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-11468xxxx-1');
</script>
Website Error
[24-Feb-2018 00:58:01 America/New_York] PHP Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "/home/xxxxxxxx/public_html/tmpl/header.tpl" on line 9 "function gtag(){dataLayer.push(arguments);}" - Unexpected ".", expected one of: "}" <--
thrown in /home/xxxxxxxx/public_html/inc/libs/smarty3/sysplugins/smarty_internal_templatecompilerbase.php on line 9
I am not developer of this script but this script is working 100% perfect without Google Analytics code. So when I add Google Analytics code then site goes down.
How to solve this error, help me please?
Terry |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat Feb 24, 2018 11:08 am Post subject: |
|
|
Place every foreign snippet into a separate template, wrapped into {literal}'s when necessary.
And {include} them from main template.
You can set a fixed cache_id to them to indicate that they can be heavily cached with little to no sideeffects. |
|
Back to top |
|
terryjackson Smarty n00b
Joined: 24 Feb 2018 Posts: 2
|
Posted: Sat Feb 24, 2018 12:09 pm Post subject: |
|
|
AnrDaemon wrote: | Place every foreign snippet into a separate template, wrapped into {literal}'s when necessary.
And {include} them from main template.
You can set a fixed cache_id to them to indicate that they can be heavily cached with little to no sideeffects. |
Thank you, your tip solved my problem. It looks you gave very basic information about using Smarty but since I never used Smarty earlier that's why I was stuck.
I just put Google Analytics code between {literal} {/literal} and it worked.
Thanks
Terry |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|