Jump to content

Keeping GA tracking code inside <head></head> with "Move JavaScript to the end" enabled in PS 1.6


Recommended Posts

The Google Analytics tracking snippet needs to be inside the <head></head> tags to get accurate reporting. but to keep the load time of the site low, it is best practice to move all JS to the bottom of the page.

 

PS. 1.6 has an option in Admin (advanced parameters -> performance) to "Move Javascript to the end" 

 

Does anyone know how to keep that option enabled, but also keep the GA Tracking Code from moving to the bottom? 

Link to comment
Share on other sites

  • 3 weeks later...

I've tried that, and now I know why we dont need to do that. Google Asynchronous tracking automatically load the javascript after the page is loaded, no matter where we put the analytic js. So don't mind about moving it to the <head>.

 

Thanks for replying btw

Link to comment
Share on other sites

  • 6 months later...

Hello,

I just found this solution as i was looking to keep Google Tag Manager script just after the first <body>.

 

1 - Create a Media.php override that'll say to not move the scripts you want (details in the link below)

2 - insert data-keepinline="true" in the scripts you don't want to be moved

 

All details here (in french) : http://www.prestarocket.com/blog/prestashop-google-tag-manager/

Link to comment
Share on other sites

×
×
  • Create New...