- Priority: 0
- Status: Closed
- Theme: Alysum
-
Assigned To:
Fred
- Private: No
- Open Date: 03.05.21, 17:11
- Opened by: Marianne van der Sluis
- Closed by: Anonymous Submitter
- Closed on:
- Reason: Not a bug
Ticket #21441 - Google Analytics does not work with "scripts attribute: defer"
Hello,
Took me a while to find out why GA did not work anymore.
But I found it.
To make our site a little faster I activated in the theme-settings –> scripts attribute: defer
I tried Async first but if i select that, the script to put things into the shopping cart from the category-page does not work and the buttons keep spinning.
So I tried “defer”
@ questions:
Is there a workaround to use “defer” and also to have the GA still getting information?
We use a module called: Premium Google Analytics Enhanced Ecommerce
Or would what is your advise? Maybe just use scripts attribute: none ?
Does it make much difference in page-loading speed?
Comments
Hi, Marianne van der Sluis.
1. You can read more about defer an async option here https://flaviocopes.com/javascript-async-defer/ all depends on your modules set. Some modules requires one option some another one. Just try which one will work for you
2. As for the Google Analytics, one of possible solutions is to enable Native Footer option in the Theme Settings. You can find more information in the documentation https://alysum5.promokit.eu/promokit/documentation/pkthemesettings/#footer
Hi Fred,
Thank you for the response.
If I enable the native footer, i can see where i can do that, why do i do that? Do I then hook the google analytics module to the footer?
Only enabling the native footer, in combination with the use of the module and scripts attribute: defer did not make a diffrence, I then still get no results in Google Analytics
scripts attribute: defer
–> Google analytics script does not work
scripts attribute: async
–> add to cart script from category-page does not work
How can the native footer help with a workaround?
1. try to select “none” option
2. From the documentation
OK I’ll keep it on “none”
“Native Footer — this option enable native prestashop footer hook “displayFooter”.
Sometimes this option can be useful because some modules use this hook to output technical information.” .. i did read that but it does not help me understand what i can do
–> do i activate this option and then hook the Analytics module to that location?
I assume the Analytics module already hooked there, that’s why I ask to try to enable Native Footer option
Yes I don’t know if it hooked there but when I activated the native footer in combination with scripts attribute: defer
Google analytics script did not work. Just tested again
Have you tried to reset your analytics module?
Yes and updated to the latest version.
I have checked out your configuration and everything seems to be correct - https://take.ms/qW5Qt
Please check out the module documentation, maybe you will find some suggestions there https://docs.reactioncode.com/en/modules/prestashop/premium-google-analytics-enhanced-ecommerce/