question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: cookie consent

See original GitHub issue

Struggled with adding a cookie consent banner via Google Tag Manager (GTM) injection until a frontend colleague helped. Since I could not find anything about this topic related to mkdocs or mkdocs material I thought I’d open an issue here for others to google. Could maybe be added as a feature if relevant for more people, otherwise feel free to close soon.

HOWTO: Use the mkdocs theme override functionality and create a main.html file with the following javascript code taken from here. The first, custom part of the code ensures that the GTM is not being active when running mkdocs serve locally since this blocks from interacting with the site. Also see this PR and repository as an example for the structure of the overrides.

<!-- Elements added to main will be displayed on all pages -->
{% extends "base.html" %}

{% block libs %}
<!-- Google Tag Manager -->
<script>
var gtmId = 'GTM-YOURGTMCODE;
if (typeof window !== 'undefined' && window.location.href.includes('127.0.0.1')) {
  gtmId = 'GTM-XXX'
}
(function(w,d,s,l,i){
  w[l]=w[l]||[];w[l].push({'gtm.start':
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  })(window,document,'script','dataLayer', gtmId);
</script>
  <!-- End Google Tag Manager -->
{% endblock %}

Description

If this would be added by default I could imagine it being used similarly to the Google Analytics tag in the mkdocs.yml file. Depending on your GTM configuration adds a cookie banner. However probably not relevant for too many users. Don’t know much about cookies and was also told that when using Google Analytics anonymized this would not actually be neccessary (was still decided to add it for the future).

Screenshots / Mockups

image

  • … the documentation does not mention anything about my idea
  • … to my best knowledge, my idea wouldn’t break something for other users
  • … there are no open or closed issues that are related to my idea

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:32 (25 by maintainers)

github_iconTop GitHub Comments

7reactions
squidfunkcommented, Mar 7, 2021

I’ve moved other features up the priority list, but I will try to provide a simple yes/no implementation in the coming weeks!

5reactions
squidfunkcommented, Oct 17, 2020

Thank you all for the input on this topic. I’m still wondering whether there’s any value in providing a completely self-contained solution for this, i.e. asking the user, setting a value in local storage, and firing an event when the value in local storage allows for tracking. What we could do is provide a simple yes/no solution for Google Analytics. Anything else would require some customizations, obviously, as there are too many potential services to integrate. So wrapping this in a template block could work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[New Feature Request] Ask the user before adding cookies ...
Hello,. at the moment the plugin is adding the Cookies Categories to the sitemap without asking the user first. I think this should...
Read more >
Feature requests - The Privacy Suite for WordPress - Complianz
Feature -request: Possiblity to add list of sites where cookie-Banner is not shown and no trackers are loaded. Under Review Category: Usability. 1...
Read more >
Cookie Consent component | Voters - Docusaurus
There is a significant demand from within Facebook for a cookie consent banner to be implemented. Users should be allowed to make use...
Read more >
How Must I Manage Cookie Consent in Order to Be Compliant
No, the Cookie Law does not require that you list and name individual cookies. You are instead explicitly required to clearly state their...
Read more >
Cookie consent | Build trust with your end-users - Cookiebot
Cookie consent is crucial to get right on your website – strict data laws apply to ... The geotargeting feature of our CMP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found