Plugin does not load code after consent received

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #29403

    lccllc
    Participant

    Hello,

    The plugin does not load the code after consent is received.

    It ONLY works if we enable Reloading. And for obvious reasons, page reloading is a nuisance.

    What is required to make the code load after constant received without a forced page reload?

    Thanks,

    Len

    #29477

    lccllc
    Participant

    Hello – can someone please help me with this?

    #29963

    romanbae
    Participant

    Hi!

    I have exact the same problem. Did you find a solution?

    #29965

    romanbae
    Participant

    I also tried to execute the code manually, but I can’t detect if the user has accepted the data because cn_cookies_accepted() is not known:
    Uncaught ReferenceError: cn_cookies_accepted is not defined

    #29966

    romanbae
    Participant

    Got it! There are two problems.

    1st one: The code is not directly rendered to the output.
    The PHP file defines:
    if ( $this->cookies_accepted() ) { … }
    but the cookie is not yet accepted when this line of code is handled.

    2. When accpeting an event is triggered. ‘setCookieNotice’ But this event was never registered!
    $.event.trigger( {
    type: ‘setCookieNotice’,
    value: cookie_value,
    time: date,
    expires: later_date
    } );

    So my solution for google analytics (works with others too).
    Use a plugin like Header and Footer Scripts and write a function for enabling google analytics. That is the code you would usually define in Cookie Notice’s not functional code area.

    <script>
    enableGoogleAnalytics = function(event) {

    var gaProperty = ‘xxx’;
    … and so on… Google code..

    }

    jQuery(document).on(‘setCookieNotice’, function(event) {
    if (event.type == ‘setCookieNotice’ && event.value == ‘true’) {
    enableGoogleAnalytics();
    }
    });
    </script>

    As you can see, there’s a second script, which registers the setCookieNotice event. It invokes enableGoogleAnalytics() when the Cookie Notice’s button was clicked.

    Finally you have to put a simple
    <script>
    enableGoogleAnalytics();
    </script>
    in Cookie Notice’s script area. This triggers google analytics when the cookie was accepted some times ago…

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.