• Resolved Daniel P.

    (@danidub)


    Hello, we are having some issues with the Javascript consent variables on our website, I’ll try to explain.

    If a user enters our website we see the banner, we click on “save” and this will save only strict cookies, the page reloads and the Javascript variables are correct:

    /* <![CDATA[ */
    var gdpr_consent__strict = "true"
    var gdpr_consent__thirdparty = "false"
    var gdpr_consent__advanced = "false"
    var gdpr_consent__cookies = "strict"
    /* ]]> */

    We open again the banner and it shows also ok, having selected only necessary.

    If we change and allow third party on the cookie banner, the page reloads and the Javascript variables are not updated:

    /* <![CDATA[ */
    var gdpr_consent__strict = "true"
    var gdpr_consent__thirdparty = "false"
    var gdpr_consent__advanced = "false"
    var gdpr_consent__cookies = "strict"
    /* ]]> */

    But, if we opened again the banner the selection is correct, having the strict and thirdpary cookies selected, the problem is that this is not reflecting in the Javascript variables.

    If we navigate to another URL, the JS variables are magically updated:

    /* <![CDATA[ */
    var gdpr_consent__strict = "true"
    var gdpr_consent__thirdparty = "true"
    var gdpr_consent__advanced = "false"
    var gdpr_consent__cookies = "strict|thirdparty"
    /* ]]> */

    What can be happening here? We have disabled all JS cache for testing purposes.
    Any ideas? Could this be the browser cache?

    Thank you.

    • This topic was modified 7 months, 1 week ago by Daniel P..

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Moove Agency

    (@mooveagency)

    Hello,

    Thanks for using our plugins.

    We were able to replicate the issue – it is caused by object-cache:
    https://wpengine.com/support/cookies-and-php-sessions/

    We would recommend whitelisting the following cookie name moove_gdpr_popup?using PHP syntax such as $_COOKIE['moove_gdpr_popup'] with your hosting.

    Or you may have to try a different cookie reading method, such as reading values via JavaScript (see our plugin documentation) or switch to the new consent mode implementation.

    Hope this helps

    Thread Starter Daniel P.

    (@danidub)

    Hey guys!

    Is not object cache but a page cache issue. We are using the JavaScript variables to signal GTM and they are falling under page cache on WP-Rocket. Maybe they are being generated by PHP (I don’t know) but they are being cached.

    I have created a custom script on JS that reads the value of the cookie moove_gdpr_popup and creates again the variables on our code. This is working on any cookie update and not falling under page cache. GTM signaling is now working as it should.

    So I think that anyone using your plugin and using the JS variables is having this same issue. Maybe you can check it and work on another solution for those JS vars not being cached.

    Thank you!

    • This reply was modified 7 months, 1 week ago by Daniel P..
    Plugin Author Moove Agency

    (@mooveagency)

    That’s true, the page cache by WPRocket could affect these variable because it uses PHP cookie checker.

    The only way for you to read the GDPR cookies is the JS version, or to turn off the page cache in WPRocket.

    The wp consent api connection could also be a possible solution
    https://www.ads-software.com/plugins/wp-consent-api/
    (latest version of our plugin fully supports the integration):
    Because our plugin has only 3 category in total, and the naming is different, we used the following matching:

    • Strictly Necessary => functional
    • 3rd Party => statistics
    • Advanced => marketing

    Hope this helps.

    Thread Starter Daniel P.

    (@danidub)

    Hello!

    Wouldn’t be better to make a change on your plugin and create the JS variables directly using JS? I have created a little snippet that reads the cookie values and expose the JS vars (all in JS).

    That way the variables are being created and updated on any user change. Maybe you can change how your plugin generates those JS vars and improve for this type of cases.

    Thank you!

    Plugin Author Moove Agency

    (@mooveagency)

    Hello,

    The JavaScript variables can be cached too by caching plugins, that’s why we’re storing the values into moove_gdpr_popup cookie.

    If the PHP version doesn’t work, you can start using the Consent API plugin that our plugin is compatible with (https://www.ads-software.com/plugins/wp-consent-api/) and use their JavaScript examples to setup the variables.

    Hope this helps

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘GTM / Javascript consent variables problem’ is closed to new replies.