Return to Support

Implement Google Cookie code – how?

Home Forums Graphene WordPress theme Support Implement Google Cookie code – how?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9333
    Fritsjof
    Member

    Hi,

    Today I decided to finally implement the cookie bar so EU visitors can agree on the cookies that are placed on their machines while using my website.

    Google opened up a nice website with code snippets so I wen on using it:

    https://www.cookiechoices.org/

    The website reads:

    In order to implement this JavaScript solution you will need to copy and paste this code into the <body> of your page. You will also need to download the cookiechoices.js file and upload that file to your server directory.

    So I put this code on the footer.php file of my WP sites:

    <!-- You should make sure that the file cookiechoices.js is available
    and accessible from the root directory of your site. -->
    <script src="/cookiechoices.js"></script>
    <script>
    document.addEventListener('DOMContentLoaded', function(event) {
    cookieChoices.showCookieConsentBar('Your message for visitors here',
    'close message', 'learn more', 'http://example.com');
    });
    </script>

    Before the </body> tag, the put the .js file in the root of my sites using FTP, then cleared all W3 caches and voila! Working like a charm.

    Then I had to do it for my WP sites that use the Graphene them, and there I ran into trouble: the cookie-bar is not showing up. I tried the code in the footer, in the header, cleared caches, put the .js file on multiple places to be sure it’s there.

    Nothing.

    Does anyone have any idea where I should place the code in order to get it working?

    Thanks a bunch!

    #43382

    You are only obligated to show the cookie consent if your server is located in the EU. I take it your is?

    If so, there are a number of plugins which will handle this for you much easier than the messy way listed above, which is not for WordPress sites.

    #43383
    Fritsjof
    Member

    Kenneth, thanks for your reply.

    Yes, both the server and the intended audience for my websites are located in the EU, therefore the cookie-annoyance is mandatory.

    Any plugins you can recommend for implementing a cookie-wall, one that works smoothly with the Graphene theme specifically?

    Thanks again for your help.

    #43384

    I don’t use any, but there is a list in the plugin repository here:

    #43385

    I don’t use any, but there is a list in the plugin repository here:

    https://wordpress.org/plugins/search.php?q=eu+cookie

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.