• Hello all, first of all thanks for the nice plugin!

    I have problems with the plugin and wp-rocket.

    First, to check what could cause the error I have disabled all of the js and other possible optimization of wp-rocket but nothing works I still have problems.

    The problem:
    On safari only, when I am on a woocommerce category (from the wp-rocket cache) and I click on a product, and then I click on the safari back button, instead of staying on the woocommerce category, I am automatically (or automagically!) redirected to the product I just saw.
    Example: – I am on a category page (ie categoryA)
    – Click on a product (ie productA)
    – The productA page is loading right
    – Click on the safari back button
    – The categoryA page is displaying (as it should be)
    – THEN after 2-3 seconds, I am redirecting (without doing nothing) on the productA page

    What could happen ?

    Thanks in advance for the help!
    Best regards !

Viewing 11 replies - 16 through 26 (of 26 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    I did some research on the net for this and found it is actually an issue since years but for GTM4WP this was not a problem before v1.13

    What changed in v1.13?
    With the introduction of GA4 tracking, I saw a new issue happening when clicking on products in product lists: the select_item event (which is the GA4 equivalent of gtm4wp.productClickEEC) fired twice or even multiple times on each click.

    This was happening because GA4 tracking actually loads gtag.js which is technically another container and GTM calls event callback functions with each loaded container. Therefore select_item was first fired because of the GTM container and then because of the GA4 tracking. This is why the issue disappeared when you paused GA4 tags.

    To prevent this from happening, I changed the behavior in v1.13 by saving the product ID into a global JavaScript variable so that each product click is only tracked once and if someone is opening a new tab by keeping the Ctrl button pressed, it also deduplicates multiple clicks on the same product.

    Now this works in every browser except Safari since Safari is literary resurrecting the previously loaded page when you hit the back button. This means that after hitting the back button you are not send back to a new instance of the product list page but the previously visited page with all the JavaScript variables and states restored. This makes the mess.

    Developers all over the world face this issue with different use cases:
    https://www.google.com/search?q=safari+not+reloading+page+after+back+button

    The suggestion in most cases is to detect the fact that there was a navigation in Safari as such and force the category page to reload:
    https://stackoverflow.com/questions/33860241/safari-back-button-doesnt-reload-page-when-used
    https://developer.mozilla.org/en-US/docs/Web/API/PageTransitionEvent/persisted

    I would add an additional check for the user agent to only reload pages in Safari if needed.

    Some say bigger players also use this technique although I haven’t checked this by myself yet.

    I have however some doubts how this will affect UX

    Thread Starter amauryt

    (@amauryt)

    Hello @duracelltomi

    Thanks for the reply and the explanation.

    It make sense, safari is often doing things differently…

    I think your solution to reload the page if the back button is clicked and user agent is safari is a necessary workaround, but it should not only be done on category pages, but on all pages where a select_item event could happen.
    Indeed, this problem appears also for example if I am on a product page and I click on another product of the page (ie Related products list) and come back.

    When do you think a fix would be available ?

    Thanks again for the time and help !

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Could you test this patch on your site?
    https://github.com/duracelltomi/gtm4wp/commit/96a936a369bb13720435aaf8da7f1e9f20cbba9f

    You should also reactivate GA4 tags in order to see whether this resolves all issues in Safari

    Thread Starter amauryt

    (@amauryt)

    Hello @duracelltomi,

    Thanks for the patch, I have activated it on my preprod and reactivated the GA4 tags.

    It “resolve” the safari back button, but, and I don’t know if it could be done otherwise, in term of UX experience it is visible :
    For example, If I am in a middle of a category page, click on a product and come back, I’m going on the middle of the category page, then after 0.5/1s the reload page happen, and the page reload to the top of the page, and then 0.5/1s after, we are scrolled to the middle of the page, so there is some “delay” and visible scrolling before getting back to where we were.

    Thanks again for the help,

    BR

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    Thanks for the feedback.
    I was afraid of that. I do not think this patch will get many likes if released ??

    I will continue to think of how this could be resolved using other ways.

    Thread Starter amauryt

    (@amauryt)

    Hello @duracelltomi

    Thanks to you, hope you will be able to identify a solution soon :/

    BR

    Thread Starter amauryt

    (@amauryt)

    Hello @duracelltomi

    Do you have some updates about a potential fix for this issue ?

    Hope yes ??

    Best regards and thanks again a lot !

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    Not yet but I will let you know once I find something better ??

    Thread Starter amauryt

    (@amauryt)

    Hello @duracelltomi

    Do you think this problem will be fixed soon ?
    My website run without google analytics for some time now and I would really love to be able to reactivate it. (or to be able to find some alternatives if no fix will be released :/)

    Thanks again a lot for this plugin, the time, and the help !

    BR

    Thread Starter amauryt

    (@amauryt)

    Hello @duracelltomi

    Is there some news regarding this issue ?
    Am I the only one facing issue with your plugin and caches ?

    Thank you for your help and patience,

    Best Regards

    • This reply was modified 3 years, 1 month ago by amauryt.
    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    There is a new beta version available:
    https://github.com/duracelltomi/gtm4wp/releases/tag/1.14beta3

    Could you test it as it includes some more changes that might be related to this topic?

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘Problem on safari with wp-rocket and gtm4wp’ is closed to new replies.