-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Magento 2.2.5: Google Analytics not added to head correctly #16497
Comments
Hi @WalterSmulders. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
where @WalterSmulders do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
@WalterSmulders, thank you for your report. I've checked this issue on Magento 2.2.5, and google-analytics.js loads for me on storefront just fine. |
Adding link to the Pull Request where this was introduced: #14293 |
@WalterSmulders, we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue. |
Did this issue ever get resolved as i'm having the same issue? |
Probably not. So before this it was a block and now it is a container? This would be a breaking change which affects all who overwrite default.xml (which is the case when you create a custom theme or extend theme files). |
@DanielRuf Thanks. I think the default theme has changed, i've inherited a project, and updated it from 2.1.8 to 2.2.5 do you know what the fix is for this? |
The fix for us who have a custom or other theme based on Blank / Luma have to port the changes to the overwritten / changed files. Good to know, will have to check this also for one of our projects. |
Basically doing a diff (changing block to container). |
We have to check here if 2.2.5 or a previous release introduced this change. |
Hi @DanielRuf seem this issue was fixed in 2.2.5 but if you have a custom theme you need overwrite odefault.xml to origin luma or blank file ? |
Hi I've updated the following default.xml file it's not working so i guess it's not the right path. app/design/frontend/-THEME VENDOR-/-THEME NAME-/Magento_Theme/layout/default.xml
What file exactly do I need to update? |
@eamontaylor this is right path -> app/design/frontend/-THEME VENDOR-/-THEME NAME-/Magento_GoogleAnalytics/layout/override/base/default.xml |
@engcom-backlog-nazar nope this doesn't work for me. Upgraded, Compiled, Deployed, Cleared cache and still nothing, |
@eamontaylor did you clear pub static files? |
@eamontaylor If you correctly override the XML it will work, I have this fix in place in several live Magento installs |
@eamontaylor you may do something wrong, i do this with custom theme and it works perfectly. |
@DanielRuf Can i close issue ? or leave open, until somebody change name from container to block ? |
Do i need to change refernceContainer to referenceBlock? |
@eamontaylor yes but seems it's not solve your problem. |
@engcom-backlog-nazar Thanks, i've tried everything you've suggested but still no joy. |
@DanielRuf Yep cleared the caches again and that seems to of sorted it thanks everyone. |
I believe @WalterSmulders has a point here.
The strange thing is, that this seems to work perfectly fine. So you can reference a block using I'm not sure if customisations can break this somehow, but I think it would be best that the |
@WalterSmulders , thank you for your report. |
@engcom-backlog-nazar happy to hear the bug is acknowledged and it will be fixed |
#mm18hr |
Hi @WalterSmulders. Thank you for your report. The fix will be available with the upcoming 2.3.1 release. |
Hi @WalterSmulders. Thank you for your report. The fix will be available with the upcoming 2.2.8 release. |
Good afternoon, Just one typo error with the script declaration "Smile_ElasticsuiteTracker::js/tracking.js" (anyway, it include correctly this javascript file). And some inconsistents with the declaration of head.additional which is a block not a container (Same problem on Magento_GoogleAnalytics, this is not solved in my version of Magento 2.3 - magento/magento2#16497) Personally, I would rather move the script tracking.js into the before.body.end before block smile.tracker.page.base. I think you recommends to place it in the <head>, so if someone aborts a load of the page, the script might get executed. "It helps you to accurately record traffic stats because your header scripts are loaded earlier than any other scripts on your page." Cheers, Ilan PARMENTIER
I am on 2.2.7. I experience the exact same issue with the Adwords block (... while the Analytics block is working for me). Any comments on that? |
@WalterSmulders can you please make a comment on this? |
I did not experience this issue. I recommend to see if the fix I gave in the opening post can be applied to the Adwords block, furthermore I think it's wise to treat this as a separate issue since this one is closed and likely contains a other part of the code. |
@WalterSmulders ok thanks I wil investigate and post a new issue if necessary |
The Google Analytics code is still not being properly added to the head in 2.2.8. I applied the fix in 2.2.7 as a layout extension - theme-dir/Magento_GoogleAnalytics/layout/default and it worked properly in 2.2.7 after it was applied. I upgraded to 2.2.8 and removed the layout customization, but now the code is not being added properly as it was before. Also, I have cleared all my caches but that hasn’t solved my issue. |
I resolved my issue. It was due to another layout extension I had within theme-dir/Magento_Catalog/layout/default.xml. I didn't realize that the latest fix in 2.2.8 referenced that. |
Preconditions
Steps to reproduce
Expected result
Actual result
I managed to find the problem myself. In Magento 2.2.5 the file Magento_GoogleAnalytics/view/frontend/layout/default.xml was changed.
It now injects the Google Analytics block trough:
<referenceContainer name="head.additional">
But head.additional isn't a container but a block.
The fix I am using is to create a file:
app/design/frontend/-THEME VENDOR-/-THEME NAME-/Magento_GoogleAnalytics/layout/override/base/default.xml
with following content:
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="head.additional"> <block class="Magento\GoogleAnalytics\Block\Ga" name="google_analytics" as="google_analytics" template="Magento_GoogleAnalytics::ga.phtml"/> </referenceContainer> </body> </page>
The text was updated successfully, but these errors were encountered: