• Resolved dajanas

    (@dajanas)


    Hello,

    I would like to use Google Analytics in combination with the plugin “Cookie Notice”. Whenever a user accepts the cookie, the Google Analytics code should be active, if the user does not accept, the Google Analytics code should (of course) not be active. Cookie Notice allows to just use a code when a user accepts the cookie, BUT in combination with W3 Total Cache and cached pages it does (of course) not work properly. Because whenever I purge caches and a user does accept the cookie, the Google Analytics code gets active. But whenever an other user visits this specific page after that, he gets asked about the cookie again (which is right), BUT because the page is already cached, the Google Analytics code is already active in the source code and stays there until I purge the page again.

    So how could I use W3 Total Cache + Cookie Notice + Google Analytics all together? Because it is unfortunately necessary because of DSGVO.

    I was not able to find a solution.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @dajanas,

    There is a couple of things that you can do regarding this. You can Use page fragment cache around the analytics script (check our FAQ for Page Fragment Cache details) or use a plugin that uses javascript to handle analytics based on cookies

    Thread Starter dajanas

    (@dajanas)

    Thank you for your answer! I will take a look at this! Could you recommend a plugin, that uses javascript to handle analytics based on cookies? Is there any that works well in combination with W3 Total Cache?

    Thread Starter dajanas

    (@dajanas)

    I can′t get this fragment cache to work. I always get the error message:

    Invalid mfunc tag syntax. The correct format is: <!– W3TC_DYNAMIC_SECURITY mfunc PHP code –><!– /mfunc W3TC_DYNAMIC_SECURITY –> or <!– W3TC_DYNAMIC_SECURITY mfunc –>PHP code<!– /mfunc W3TC_DYNAMIC_SECURITY –>

    When loading the page. I had set the wp-config like that:

    define( ‘W3TC_DYNAMIC_SECURITY’, ‘myownstring’ );

    and then set this to the header.php:

    <!– mfunc myownstring–>

    <!– /mfunc myownstring–>

    It does not work at all. My page cache is set to “Alternative PHP Cache (APC)”.

    What is wrong?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,
    Yes, it does work. When using Page Fragment Cache, make sure to enable Late initialization.
    Also, add mfunc and mclude to Ignored comment stems: in the Minify settings if it is enabled.
    I.E. syntax
    <!– mfunc mysecurestring –>any PHP code<!– /mfunc mysecurestring –>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘W3 Total Cache + Cookie Notice + Google Analytics’ is closed to new replies.