I am using Gallery 2.3.
Google analytics have changed their code from Urchin to gs.jsp. When i paste the new code into the theme.tpl footer the page, the gallery and nothing else loads. The whole website just goes blank. How can I solve this?
The website where it is installed:
http://www.alternativephotography.com/gallery/main.php
OLD URCHIN CODE:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1949563-1";
urchinTracker();
</script>
NEW GOOGLE CODE:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-1949563-1");
pageTracker._trackPageview();
} catch(err) {}</script>
Very grateful for any help!
Posts: 16503
Make sure your javascript is wrapped with {literal}
Example:
{literal}
<script....
REST OF JAVASCRIPT
</script>
{/literal}
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 114
That worked, thank you! Just a question, do i have to do this with all JavaScript? There is Google ad code before that is also JavaScript, but the Gallery ran fine without the {literal} tags on this code...?
Posts: 4338
It's not specifically a javascript issue.
Any time you want to put a { or a } in a smarty template (.tpl) file you have to find some way to stop Smarty from interpreting it as the beginning or end of a Smarty tag. Javascript uses { and } characters, so it crops up as an issue with Javascript. Either put the whole section in between Smarty {literal} and {/literal} tags as Nivekiam suggests or you can replace every { with "{ldelim}" and every } with "{rdelim}" instead.
http://www.smarty.net/manual/en/language.function.ldelim.php
Posts: 114
Ok, got it, that's why the JavaScript a few lines above works just fine... it has none of those... thanks a lot!
Posts: 22888
AlternativePhot...
Can you update the codex page to adding Google analytics to assit others?
http://codex.gallery2.org/Gallery2:How_To_Add_Google_Analytics_to_my_Gallery_2
Your contribution will help others with the same issue in the future.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 114
I'd be happy to, can you add me to the group "User" somehow?
When I want to edit, it says:
"The action you have requested is limited to users in the group Users."
And the link "users" takes me nowhere.
Posts: 16503
You'll need to create an account on the wiki. The user management for the codex (wiki) is separate from the forums.
http://codex.gallery2.org/index.php?title=Special:UserLogin&type=signup&returnto=Gallery2:How_To_Add_Google_Analytics_to_my_Gallery_2
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 114
Done, and changed the codex!
Posts: 22888
Thanks!
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team