• Closed by: Alex
  • Closed on: 31.10.15, 10:03
  • Reason: No answer from a customer
  • Comment: Glad to help!

Ticket #8405 - Errors when I turn off the "Move javascript to end" option

Good afternoon! Please we need to know why it does our website not work normally when I disable “Move javascript to end” option (enclosed capture how the site looks like when this option is disabled)

We need to turn this option off, as we believe that it is creating conflicts with Google Analytics module. The latter precisely placed in the <head>, and the “Move javascript to end,” takes you to the last code option.

Comments

Alex 10 Sep 2015, 10:55

Hi. For normal theme work this feature should be always enabled. We have a lot of customers and they don’t have problems with the Google Analytics.

Soporte Criterio 10 Sep 2015, 14:25

Hi, thanks for your answer.
When we deactivate this option, Analytics not working properly… You can help to know how to place fixed analytics script in the <head>? For this option does not lead to the end of the code and give an error.

Alex 10 Sep 2015, 16:29

How do you use GoogleAnalytics? Default ps module?
Where do you see GA error?

Soporte Criterio 10 Sep 2015, 16:37

I used the Google Analytics module, but now put the code directly in the <header> in the file header.tpl
In both cases (using the module and by direct code) google analytics error alerts me that the code is outside the head. Therefore it consulted on the “Move javascript to end” option because that’s what it takes to last the script code.

This is the code entered in <head> of header.tpl file:

{literal}
<script>
	(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	ga('create', 'UA-XXXX-Y', 'auto');
	ga('send', 'pageview');
</script>
{/literal}

How you could set this script to not drag the end of the code and is respected and maintained within the <head> ??